Tagged
design-principles
- Liskov Substitution: A Matching Signature Does Not Mean It Can Be Swapped In
Refund channels can share method signatures while behaving differently for their callers. Reversals, settlement receipts and state history show how four contract checks work, and what types, capability interfaces and contract tests can protect.
- The Open-Closed Principle: Which Changes Should the Design Accommodate?
Adding a refund channel leaves existing implementations alone, while adding a reversal operation reaches across them. Comparing interfaces and union types shows what the open-closed principle can protect, and when an abstraction earns its place.
- Single Responsibility: A Responsibility Is Not a Task, It Is Someone Who Will Ask
Single responsibility is usually taught as "a class should do one thing", a sentence that cannot be used to judge any code. In 2014 Martin said it plainly: this principle is about people. Split the four groups of requirements living inside one refund service, and what you get is another way of stating cohesion and coupling.
- Coupling: Three You Cannot See, and a Dependency That Moved House
Coupling often gets reduced to counting imports. That holds up on the textbook violations and fails on production code. Replace a direct call with an event bus and two imports disappear, but the dependency has not gone anywhere. It has moved out of the compiler's sight.
- Cohesion: Six Levels, and Where Intuition Fails
Cohesion is usually defined as how similar the elements inside a module look. That reading survives the obvious violations and fails on production code: handlers that branch by refund channel have near-identical names, and still land in the lower half of the 1974 scale.
- Seven Design Principles Are Not a Pyramid
The seven principles of object-oriented design are usually drawn as a pyramid, each layer holding up the next. Check where each one came from and the picture falls apart: six unrelated groups of people, twenty-two years apart, and at least two of them give opposite advice about the same code. This is the opening note of the Programming Thinking series.