Class Design Principles
About Class Design Principles
Class Design Principles …
Class Design Principles ...
- state desired properties of class designs. E.g. “A class should have only one responsibility.”
- are heuristics that serve as guidelines to produce good designs.
- are not absolute criteria to judge about the quality of designs.
- help making a class design usable for client classes. We think about how our classes are used by other classes.
Class Design Principles aim for code we can efficiently work on!
The S.O.L.I.D. Principles:
- Single Responsibility Principle (SRP)
- Open-closed Principle (OCP)
- Liskov Substitution Principle (LSP)
- Interface Segregation Principle (ISP)
- Dependency Inversion Principle (DIP)
During its lifetime of a software the (class) design changes constantly. This is a consequence of requirement changes which is the rationale for conducting an iterative design process.
Class Design Principles are not only about the current state of the code, but also give you an understanding of how well the code will be under the effect of change. Especially whether and how changes will affect client classes.