开发者

Connection between GoF Design Patterns and SOLID

开发者 https://www.devze.com 2023-04-04 17:24 出处:网络
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 Depe

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

精彩评论

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

关注公众号