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.

askedSep 14, 2011 at 17:53
Ronald's user avatar
2

3 Answers3

4

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

  • S: Single responsability principle: the classes that are part of theDP, have only one responsability
  • O: Open/Closed principle: it is easyto extend with new functionality, for example the strategy patternallows you to implement an additional algorithm without having tochange the other classes that contain other algorithms
  • Liskov Substitution Principle: also applies to strategy for instance
answeredSep 14, 2011 at 17:58
Frederik Gheysels's user avatar
Sign up to request clarification or add additional context in comments.

2 Comments

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.
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.
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

answeredSep 14, 2011 at 17:56
Aravind Yarram's user avatar

1 Comment

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.
0

There's a paperA reference model for low level design, which lists the SOLID properties for some patterns in table 3:

  • Facade: ISP, DIP
  • Chain of Responsibility: SRP, OCP, LSP, ISP, DIP
  • Decorator: SRP, OCP, LSP, ISP, DIP
  • Factory: SRP, OCP, ISP, DIP
  • Builder: SRP, ISP, DIP
  • Adapter: SRP, ISP, DIP

I'd like to see such research for all patterns, but I'm not aware of similar papers.

answeredFeb 14, 2024 at 15:34
Thomas Weller's user avatar

Comments

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.