Design Principles and Patterns

D in SOLID – Dependency Inversion Principle. Short explanation with example.

Here are 3 statements, all of which means the same thing: Depend upon Abstractions. Do not depend upon concretions. High-level modules should not depend on low-level modules. Both should depend on abstractions. Abstractions should not depend on details. Details should depend on abstractions. This principle was introduced by Robert Martin together with the rest 4 SOLID principles. In my opinion it…

Continue Reading

Design Principles and Patterns

I in SOLID – Interface Segregation Principle. Short explanation with example.

Clients should not be forced to depend upon interfaces that they do not use Rober Martin This principle, similar to Single Responsibility Principal, is about avoiding redundant code changes when requirements change. Following this principle will save you from changing existing classes, allows to add extra functionality with just an extra class. We could also redefine this principle like this:…

Continue Reading

Design Principles and Patterns

L in SOLID – Liskov Substitution Principle. Short explanation with example.

Let Φ(x) be a property provable about objects x of type T. Then Φ(y) should be true for objects y of type S where S is a subtype of T. Barbara Liskov Sounds so confusing… But really it is not so complicated, just lets first redefine it like this: Objects of a superclass shall be replaceable with objects of its subclasses without breaking the application. That requires the objects of your subclasses to behave…

Continue Reading

Design Principles and Patterns

O in SOLID – Open/Closed Principle. Short explanation with example.

Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification Bertrand Meyer This statement was introduced by Bertrand Meyer in 1988. And it basically means that: A class is treated as open if it is available for extension. I.e. possible to extend by adding extra attributes or methods. A class is treated as closed, if…

Continue Reading

Design Principles and Patterns

SOLID Software Design Principles. Summary.

SOLID – an acronym, which stands for 5 components: Single Responsibility Principle. A class should have only one task (responsibility), which it takes care of. Open/Closed Principle. It should be possible to extend class functionality without modifying it. Liskov Substitution Principle. Base classes should be substitutable by their derived classes. Interface Segregation Principle. Client specific interface is better than one…

Continue Reading