The Code Design cluster
How to write code that survives change.
Why these together
SOLID and Beck's Four Rules are competing default sets. DRY, KISS, and YAGNI are rules of thumb for keeping things simple. Demeter is the locality rule. Hexagonal Architecture organises the code at the module level. Bounded Contexts and Ubiquitous Language organise it at the model level. Conceptual Integrity is the property all of this serves. No Silver Bullet is the reminder that none of this removes the essential difficulty. Leaky Abstractions and Tesler are the limits. Least Astonishment and Hick's Law are the interface-design constraints.
-
Principle SOLID Five rules for designing object-oriented code: each class does one thing, code should be open to extension but closed to modification, subclasses should be substitutable, interfaces should be small, and code should depend on abstractions rather than specifics.
-
Principle Beck's Four Rules of Simple Design A simple design passes its tests, makes intent clear, has no duplicated knowledge, and uses the fewest elements possible. The rules apply in that order.
-
Saying DRY (Don't Repeat Yourself) Each piece of knowledge in the system should live in one place.
-
Saying KISS (Keep It Simple, Stupid) The simpler version usually wins.
-
Saying YAGNI (You Aren't Gonna Need It) Do not build features you might need someday.
-
Principle Law of Demeter A piece of code should only talk to its immediate neighbours. It should not reach through them to talk to strangers.
- Pattern Hexagonal Architecture (Ports and Adapters) Put the domain at the centre. Surround it with ports (the contracts the domain offers) and adapters (the code that connects ports to the outside world).
- Principle Bounded Contexts Different parts of a system can use the same word to mean different things. Draw an explicit boundary around each meaning and translate at the seam.
- Principle Ubiquitous Language The people who build the software and the people who use it must use the same words to mean the same things. The vocabulary is the design.
- Principle Conceptual Integrity A system designed by one mind, or by a few minds in close agreement, will be easier to use and understand than one designed by committee.
- Principle No Silver Bullet There is no single technique that will produce a ten-fold improvement in productivity within a decade. The hard part is the essential complexity of the problem itself.
-
Principle Law of Leaky Abstractions Anything that hides complexity will eventually let some of that complexity show through.
-
Principle Tesler's Law (Conservation of Complexity) Every system has some complexity that cannot be removed. You can move it around, but it has to live somewhere.
-
Principle Principle of Least Astonishment Software should behave the way someone familiar with it would expect.
- Principle Hick's Law The time it takes to make a decision grows with the number of options.