Time for an 8th Virtue: Coherence
I've written repeatedly about the 7 Code Virtues, and they have been reliable guides for me, as well as a language for describing goodness in code.
When I started applying this agentically, I realised that I may have been wrong about ordering (as I suspected all along) and adjusted to 'Working is prime, the rest are equal', and this has served me well.
The agentic code still wasn't going as well as I hoped.
After a bunch of reflection, ChatGPT, and trial and error, I discovered that I was missing Coherence.
Most simply described, coherence is the degree to which concepts, abstractions, vocabulary, architecture, patterns, and representations of the system reinforce one another.
Over its evolution, a coherent system increasingly feels like a single language. This goes hand in hand with the 'developed' code virtue.
Coherent systems increase the value of learning because knowledge gained in one part of the system becomes useful elsewhere.
This raises the bar for coding, whether you are a human or an agent. It brings forward the idea that representation matters. This is doubly true when dealing with cardinalities in code.
Much software improvement comes not from adding behavior, but from finding better representations of existing ideas.
Better representations often improve multiple virtues simultaneously.
- eliminate duplication (Unique)
- reduce operands, operators, and paths (Simple)
- reveal intent (Clear)
- make change safer (Easy)
- expose domain concepts (Developed)
- concentrate signal (Brief)
- reinforce shared language (Coherent)
Tables, mappings, state machines, value objects, domain concepts, graphs, and other structures often improve software by expressing knowledge directly rather than procedurally.
Data structures, types, and patterns aren't important just because of runtime efficiency, but also because they encode knowledge in systems in a way that can be extended, consumed, and edited safely.
With this eighth concept in place, my agentic coding starts to mimic more closely what good programmers have been doing for years. Rather than producing long, stringy functions full of if statements, we start to see algorithms and data structures. Rather than loose groups of primitive variables, we start to see domain concepts encoded in types (but only when necessary).
The eighth virtue has helped to lead this in a good direction, as the agents are no longer just trying to stick functions into an existing code body; they are starting to develop and curate systems.
Comments
Post a Comment