7 Guiding the design with properties
This chapter covers
- Formal definitions of correct
- Designing around algebraic properties
- Parallel universes and how to hop between them
Writing software is hard. It's an endless fight against complexity. We've spent years coming up with design patterns and frameworks to control this complexity, but the complexity is unyielding. Development slows. Bugs rear their heads. The gap between what the requirements say the software should do and what it actually does grows steadily over time.
We all want to keep the complexity at bay, but opinions differ on how to do it. How do you decide when a design approach is "better?" When it’s SOLID? Or uses more OOP? Less? Design discussions often stalemate around mutual accusations of "complexity." One approach gets sanctified as “simple,” all others denigrated as “complex.”
But what does any of that mean? What is being measured?
In this chapter, we’re going tackle a meaning for “simple” that’s based around algebraic properties. If we can reason about the set of values that our code denotes, and what the relationships between those values mean, it has earned the label of “simpler.” If not, we keep digging until we find it.
Writing clear code requires clear thinking. Algebraic reasoning is how we do it.