5 principles of Object Oriented Class Design
- SRP (The Single Responsibility Principle): A class should have one, and only one, reason to change.
- OCP (The Open Closed Principle): You should be able to extend a classe’s behavior, without modifying it.
- LSP (The Liskov Substitution Principle): Derived classes must be substitutable for their base classes.
- DIP (The Dependency Inversion Principle): Depend on abstractions, not on concretions.
- ISP (The Interface Segregation Principle): Make fine grained interfaces that are client specific.
And 2 extra ‘guidelines‘ that is actually from procedural programming, but still applies to methods:
- One point of return: The function or method should only return a result at 1 location in the code, at the end of the function/method.
- Only one functionality: A single function or method should only have 1 functionality. In case it has more than 1, it should be split up.
[Via: ButUncleBob.com]
No Responses to “5 principles of Object Oriented Class Design”.
Leave a response