Emergent behaviour

Emergent behaviour is the source of most pain when dealing with systems. However, emergent behaviour is the only value in building systems. Without it, they are just processes, and processes are inert. All complex achievements are the success of systems. Complexity relies on interaction—the reaction to a stimulus. This establishes that all complex achievements squarely reside in the land of systems. So, we must understand the emergent behaviour of a system to be sure it does what we intend and not what we don’t.

When we think of patterns, we must not think of them as raw materials or thought-free processes. They are never modules we slap onto an existing system. They are organisations of relationships between things, between the raw materials at worst.

It’s normal for something not to be its raw materials. We can identify things as their configuration. They can be the pattern of how they move or their path of growth or reactions. A whirlpool is not just water; it is the form and energy of it. Otherwise, you could capture it in a bucket and take it somewhere else.

Forests and trees

Which bit of the following code does the sorting?

for i = last; i > first; --i:  # 1: loop over everything
   for j = 1; j < i; ++j:       # and loop inside that loop
      if val[j - 1] > val[j]:    # 2: check if we are ordered
         temp = val[j]            # 3: cache a value
         val[j] = val[j - 1]      # and copy a value
         val[j-1] = temp          # and overwrite with the cache

When we dig too deep, we deconstruct too far. We cannot see which line of code does the sorting because we are too narrowly focused. There is a flow on the outside that defines what we iterate over, but that does not sort things. A check identifies whether there is disorder, but that does not sort things. Three lines swap the order of things, but they would bring ruin if the contents were already in order.

These parts of the algorithm are the Structure in section 1, the Sensor in section 2, and the Reaction in section 3. It can sort two elements using only the Sensor and Reaction. For more, we must introduce Structure. But notice it can only do something when it has a Sensor. If it acts without observing, it is not a system. As soon as you have a structure with an observation and a resultant action, it is a system.

Patterns are forests in this way because they explain how a living collection works together to create, maintain, and heal. There’s less healing in programming, but repair is still important and shows why patterns and agile, iterative approaches are related. The observer in patterns is the programmer, observing the interplay between the code as it is and the unfulfilled requirements. The programmer reviews, decides, and acts. The pattern defines the observations you must complete to determine which of its steps to take and where.