deliberate-practice

SOLID Principles

Single Responsibility

“A class should have one, and only one reason to change.”

What is the responsibility of your class/component/service/specification/framework?

The answer can/should still be multi-tiered. Here’s one example of digging deeper into one’s responsibility by describing subcomponents’ single responsibilities as well:

Open/Close

OPEN for extension, CLOSED for modification.”

Interfaces are by definition closed for modification and require you to provide new implementations.

Liskov Substitution

“Instances of a superclass shall be replaceable with instances of its subclasses without breaking the application.”

Interface Segregation

“Clients should not be forced to depend upon interfaces that they do not use.”

A symptom of breaking this principle is when you see subtypes forced to implement methods or properties of the superclasses that they don’t use. Some times it manifests itself as empty methods, Invalid Operation Exceptions or Not Implemented Exceptions.

Dependency Inversion

“High-level and low-level modules depend on abstractions. High-level modules shall not depend on details from low-level modules.”