Mastodon hachyterm.io

The goal of the workshop is to learn the mental models and patterns to reduce complexity in software development.

The principles from the course are framework-agnostic, but the teacher uses examples from Angular.

(I found the concepts front-end centric. That’s unsurprising as the course platform targets front-end developers).

What are “enterprise patterns”?

The core problem across all enterprise software is complexity. We strive to solve complexity by diligently applying first principles.

If you run into a problem, it’s tempting to blame it on the framework. More often than not, the problem stems from a problematic implementation. Simplify the architecture to solve the root cause.

Complexity

Out of the Tar Pit by Ben Moseley and Peter Marks 1:

We believe that the major contributor to this complexity in many systems is the handling of state and the burden that this adds when trying to analyse and reason about the system. Other closely related contributors are code volume, and explicit concern with the flow of control through the system.

Look at the code:

  • Can I know the result of this code at all times?
  • Can I reuse the code?
  • Can I test this code?

It is impossible to write good tests for bad code.

The friction to testing is high because you must write testable code.

The Axis of Evil:

  • hidden state
  • violating the Single Responsibility Principle
  • nested logic

Solve via dependency injection and method extraction.

Aim for fine-grained code.

Four Elements of Programming

  1. Describing things (nouns, data structures)
  2. Performing Actions (verbs)
  3. Making Decisions (conditions)
  4. Repeating (iterators)

Object Modeling as Nouns

Take the time to properly model the domain.

Use (TypeScript) interfaces to communicate your intent.

State is a data structure.

Methods as Verbs

Managing Flow Control

Identify the things that are conventionally equivalent, and optimize/automate them.

Find the things that are not conventionally equivalent (UI, business logic), and focus 95% of your time on that.

Collections & Iterators

Prefer higher order functions (declarative vs. imperative approach).

Prefer immutability.

Use the flux pattern.

The Fifth Element of Programming

  • Time Management
  • Observables: encapsulate, transport and transform data from user interactions
  • combines Iterator and Observer pattern 2
  • Observable streams: initial output -> final input

Distributed Complexity

  • create space between interactions and effects (when using the Redux pattern: actions)
  • thin components
  • example: create stateless front-end application with web sockets and server-side state

  1. Out of the Tar Pit by Ben Moseley and Peter Marks ↩︎

  2. the best explanation I found about Observables is André Staltz’s video Two Fundamental Abstractions ↩︎