其他分享
首页 > 其他分享> > Design Principle vs Design Pattern 设计原则 vs 设计模式

Design Principle vs Design Pattern 设计原则 vs 设计模式

作者:互联网

Design Principle vs Design Pattern
设计原则 vs 设计模式

来源:https://www.tutorialsteacher.com/articles/difference-between-design-principle-and-design-pattern


In software engineering, design principle and design pattern are not the same.
在软件工程中,设计原则和设计模式是不同的。

Design Principle
设计原则
Design principles provide high level guidelines to design better software applications. They do not provide implementation guidelines and are not bound to any programming language. The SOLID (SRP, OCP, LSP, ISP, DIP) principles are one of the most popular sets of design principles.
设计原则为设计更好的软件应用提供更高层次的指导。它们不提供实现指南,也不受任何编程语言的约束。

For example, the Single Responsibility Principle (SRP) suggests that a class should have only one reason to change. This is a high-level statement which we can keep in mind while designing or creating classes for our application. SRP does not provide specific implementation steps but it's up to you how you implement SRP in your application.
例如,单一职责原则(SRP)建议一个类应该只有一个改变的理由。这是我们在程序设计或者创建类时可以记住的高级语句【译者注:个人理解,就是记住SPR原则】。SRP不提供具体的实现步骤,由您决定如何在应用程序中实现SRP。


Design Pattern
设计模式
Design Pattern provides low-level solutions related to implementation, of commonly occurring object-oriented problems. In other words, design pattern suggests a specific implementation for the specific object-oriented programming problem. For example, if you want to create a class that can only have one object at a time, then you can use the Singleton design pattern which suggests the best way to create a class that can only have one object.
设计模式提供与实现相关的低层次的解决方案,解决常见的面向对象问题。换句话说,设计模式为特定的面向对象问题提供特定的实现。例如,如果你想创建一个只能有一个对象的类,那么你可以使用单例模式,这是创建一个类只能有一个对象的最佳方式。

Design patterns are tested by others and are safe to follow, e.g. Gang of Four patterns: Abstract Factory, Factory, Singleton, Command, etc.
设计模式由他人测试好了,可以安全的遵循使用。如:四人组的模式,抽象工厂,工厂,单例,命令等等模式。

 

标签:implementation,Pattern,SRP,vs,design,Design,设计模式
来源: https://www.cnblogs.com/yejianhui/p/12200060.html