SOLID

The 5 basic principles of legible and extensible object oriented design.

Single Responsibility

A class should do only one thing. Need to connect to a database and log the time taken? Good design would have 2 classes - one for the connection and another for logging. Ideally, you would have 3 classes - the 3rd one orchestrating and calling the other 2. However, it is simpler and practical to delegate the orchestration to one of the 2 classes, or the calling program.

Open Closed

Classes should be extensible, but their existing functionality must not be changed.

Liskov Substitution

A class must not be derived from another unless the derived object can fill in for the base object in every case. The derived class retains all the capabilities of the base class.

Interface Segregation

Interfaces should be as small as practically possible. This doesn’t mean one method per interface. An interface should group only related methods together.

Dependency Inversion

Code to interfaces. Interface separate classes from each other insulating them from each other’s changes.

Design patterns are based on these 5 principles.

On May 23, 2017