3

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.

Ronald
  • 1,532
  • 4
  • 18
  • 34
  • I'm quite satisfied by the answer in this old post, http://stackoverflow.com/questions/412914/patterns-to-implement-solid-principles – Ronald Sep 14 '11 at 18:45
  • This webinar in InfoQ particularly discusses this topic, http://www.infoq.com/presentations/SOLID-Software-and-Design-Patterns-for-Mere-Mortals – Ronald Sep 16 '11 at 12:22

2 Answers2

4

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
Frederik Gheysels
  • 56,135
  • 11
  • 101
  • 154
  • I agree. It looks like one or more GoF design pattern will map to one or more SOLID principle. What I'd like is to have the complete mapping. I don't know for others but for me that will help me pick the correct design pattern based on the principle and the problem I have at hand. – Ronald Sep 14 '11 at 18:08
  • 1
    There is no complete 'mapping'. Design Patterns are solutions that can be used for a specific problem. SOLID principles are principles that you should try to apply when designing software. – Frederik Gheysels Sep 14 '11 at 20:22
1

GOF are patterns i.e. proven design solutions to recurring problems. SOLID are principles and are not tied to any specific problem domain hence true in any scenario

Aravind Yarram
  • 78,777
  • 46
  • 231
  • 327
  • There is nothing wrong with your statement. But i believe that solution to be applied it will have to be guided by a principle. That makes me believe that there is a connection between both. Knowing that connection, like knowing the principle, will make it easier to select the correct design pattern given the problem at hand. – Ronald Sep 14 '11 at 18:02