Design principles

Design principles

designandstuff


SOLID

S - Single responsibility principle

Every module/object/method must have one clear, precise and unique responsibility.

Rules to follow
New resposnibilty == New entity (module \ object \ method)
How to know if the principle is broken ?
Entity has to be changed a lot & Entity not easy to extand \ connect to other entities.

O - Open close principle

Every entity must be designed in order to be open & easy for extensions but close to changes.
Rules to follow
Abstraction using must have attributes + single responsibility.
How to know if the principle is broken ?
Entity has to be changed a lot & Entity not easy to extand \ connect to other entities.

L - Liskov Substitution Principle

Subclasses should be substitutable for base class, you can use the child as substitute to the parent.
Rules to follow
Polymorphism.
How to know if the principle is broken ?
Subclass cant substitutes parent class in all functionalities.

I - Interfaces segregation principle

Interface must contain just related attributes, unrelated should be in different interfaces instead.
Attribute that not 100% interface core must be in new interface.

Rules to follow
Polymorphism.
How to know if the principle is broken ?
Subclass cant substitutes parent class in all functionalities.

D - Dependency inversion principle

the objects that use other family of object should depend on the interface not the concretions.