开发者

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 tra开发者_运维百科nslates 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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜