Search code examples
oopsolid-principlesdesign-patterns

Connection between GoF Design Patterns and SOLID


I am interested to know which GoF design pattern translates directly to a specific SOLID principle? Like for instance I think (in my opinion) the strategy pattern translates to the Dependency-Inversion Principle.

Unfortunately, I could not find any literature that examines their relationships. It would be nice to have to learn both more effectively with each others perspectives.


Solution

  • SOLID principles are applied in most of GoF's design patterns.

    • S: Single responsability principle: the classes that are part of the DP, have only one responsability
    • O: Open/Closed principle: it is easy to extend with new functionality, for example the strategy pattern allows you to implement an additional algorithm without having to change the other classes that contain other algorithms
    • Liskov Substitution Principle: also applies to strategy for instance