The detailed-design workflow, object-oriented modeling, cohesion and coupling ladders, SOLID, composition over inheritance and the named code smells.
| Relationship | Meaning | Lifetime |
|---|---|---|
| Association | One class uses or refers to another | Independent |
| Aggregation | Has-a, shared parts | Part survives the whole |
| Composition | Has-a, exclusive parts | Part dies with the whole |
| Generalization | Is-a (inheritance) | — |
| Realization | A classifier implements an interface | — |
Weakest at the top, strongest at the bottom.
Worst at the top, preferred at the bottom.
| Principle | Statement | Violation cue |
|---|---|---|
| S — Single Responsibility | One reason to change; aligned to one actor | A class serving finance and operations at once |
| O — Open/Closed | Open to extension, closed to modification | A growing switch statement edited for every new case |
| L — Liskov Substitution | Subtypes must preserve client expectations | An override that throws UnsupportedOperationException |
| I — Interface Segregation | No client depends on operations it does not use | Implementers stubbing out methods they never need |
| D — Dependency Inversion | Policy and detail both depend on abstractions | The domain importing the database driver |
| Smell | Usual refactoring |
|---|---|
| Long method | Extract method |
| Large class | Extract class |
| Long parameter list | Introduce parameter object |
| Shotgun surgery | Move method / move field to gather the change |
| Feature envy | Move method to the class it envies |
| Duplicated code | Extract method, pull up to a common place |