I'm new to ruby on rails. I went through this and this articles, but couldn't understand the actual difference between design patterns and design principles.
我是铁轨上的红宝石新手。我经历了这篇和这篇文章,但无法理解设计模式和设计原则之间的实际区别。
Someone could please refer the best blog about design principles and patterns on Ruby on Rails?
有人可以参考Ruby on Rails上有关设计原则和模式的最佳博客吗?
1 个解决方案
#1
16
Design Principles:
Design principles are core abstract principles which we are supposed to follow while designing software. Remember they aren't concrete - rather abstract. They can be applied on any language, on any platform regardless of the state as long as we are within the permissible conditions.
设计原则是我们在设计软件时应遵循的核心抽象原则。记住它们不具体 - 相当抽象。只要我们处于允许的条件范围内,它们就可以在任何平台上应用于任何语言,无论其状态如何。
Examples:
例子:
- Encapsulate what varies.
- 封装各种不同的东西。
- Program to interfaces, not to implementations.
- 编程到接口,而不是实现。
- Depend upon abstractions. Do not depend upon concrete classes.
- 取决于抽象。不要依赖具体的课程。
Design Patterns:
They are solutions to real world problems that pop up time and again, so instead of reinventing the wheel, we follow the design patterns that are well-proven, tested by others, and safe to follow. Now, design patterns are specific; there are terms and conditions only in which a design pattern can be applied.
它们是一次又一次出现的现实世界问题的解决方案,因此我们不再重新发明*,而是遵循经过充分验证,经过其他人测试并可安全遵循的设计模式。现在,设计模式是具体的;只有可以应用设计模式的条款和条件。
Examples:
例子:
-
Singleton Pattern ( One class can only have one instance at a time )
单例模式(一个类一次只能有一个实例)
-
Adapter Pattern ( Match interface of different classes )
适配器模式(不同类的匹配接口)
The following analogy will help you understand the difference better:
以下类比将帮助您更好地理解差异:
Principle: We should teach others in order to educate ourselves as well as others, and overall make our nation a progressive nation.
原则:我们应该教别人,以便教育自己和他人,并使我们的国家成为一个进步的国家。
Pattern: In our country, each medical doctor graduate is supposed to teach 6 months in a far-away village to complete his/her degree.
模式:在我们国家,每个医生毕业生应该在一个遥远的村庄教6个月来完成他/她的学位。
#1
16
Design Principles:
Design principles are core abstract principles which we are supposed to follow while designing software. Remember they aren't concrete - rather abstract. They can be applied on any language, on any platform regardless of the state as long as we are within the permissible conditions.
设计原则是我们在设计软件时应遵循的核心抽象原则。记住它们不具体 - 相当抽象。只要我们处于允许的条件范围内,它们就可以在任何平台上应用于任何语言,无论其状态如何。
Examples:
例子:
- Encapsulate what varies.
- 封装各种不同的东西。
- Program to interfaces, not to implementations.
- 编程到接口,而不是实现。
- Depend upon abstractions. Do not depend upon concrete classes.
- 取决于抽象。不要依赖具体的课程。
Design Patterns:
They are solutions to real world problems that pop up time and again, so instead of reinventing the wheel, we follow the design patterns that are well-proven, tested by others, and safe to follow. Now, design patterns are specific; there are terms and conditions only in which a design pattern can be applied.
它们是一次又一次出现的现实世界问题的解决方案,因此我们不再重新发明*,而是遵循经过充分验证,经过其他人测试并可安全遵循的设计模式。现在,设计模式是具体的;只有可以应用设计模式的条款和条件。
Examples:
例子:
-
Singleton Pattern ( One class can only have one instance at a time )
单例模式(一个类一次只能有一个实例)
-
Adapter Pattern ( Match interface of different classes )
适配器模式(不同类的匹配接口)
The following analogy will help you understand the difference better:
以下类比将帮助您更好地理解差异:
Principle: We should teach others in order to educate ourselves as well as others, and overall make our nation a progressive nation.
原则:我们应该教别人,以便教育自己和他人,并使我们的国家成为一个进步的国家。
Pattern: In our country, each medical doctor graduate is supposed to teach 6 months in a far-away village to complete his/her degree.
模式:在我们国家,每个医生毕业生应该在一个遥远的村庄教6个月来完成他/她的学位。