Chapter 6. Divide and conquer


The previous chapter presumed that programs typically consist of multiple parts that are segregated in some way. Different areas of functionality may be developed by separate teams, modules are accessed via interfaces and packaged such that they can be replaced, and so on. Over the past few decades, much effort has been spent on syntax and semantics for defining modules in programming languages and on libraries and the infrastructure needed to deploy them. The important question is, how do we go about dividing up a problem in order to successfully solve it?

Rewinding the clock more than 2,000 years, we find one of the earliest practitioners of the governance maxim divide et regna: Julius Caesar. The idea is simple: when faced with a number of enemies, create discord and divide them. This will allow you to vanquish them one by one, even though they would easily have defeated you if they had stood united. This strategy was used by the Roman Empire both internally and externally: the key was to purposefully treat different opponents differently, handing out favors and punishment asymmetrically. And this treatment was probably applied recursively, with senators and prefects learning from Caesar’s success.[1]

1The authors have no direct evidence for this, but it sounds implausible to propose the opposite.

6.1. Hierarchical problem decomposition

6.2. Dependencies vs. descendant modules

6.3. Building your own big corporation

6.4. Advantages of specification and testing

6.5. Horizontal and vertical scalability

6.6. Summary