Open Close vs Dependency Inversion Principal [英] Open Close vs Dependency Inversion Principal

查看:62
本文介绍了Open Close vs Dependency Inversion Principal的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



虽然我已经通过很多链接,但仍然无法理解它们是如何不同的。



以下链接我已经检查过了。

- One 两个 Three Four



即使在某些帖子中,答案也没有标记。 DIP总是包含OCP而不是反之吗?

Hello Everyone,

Although i have gone through with many Links but still not able to understand how they are different.

Following links i already checked.
- One, Two, Three, Four

Even in some posts answer were not marked. Does DIP always include OCP and not vice-verse?

推荐答案

这是因为你读错了文章。



它们都是基于人为问题的错误或适得其反的表述。第一个尝试在相当无意义的代码片段中找到一个或另一个原则来做谁知道什么,其他关注vs或差异。那些vs和差异是不确定的,没有任何实际意义,这些条款中的问题是不正确的。



相反,你可能只需了解每一个这两个原则,它们的应用和价值。您可能需要从对这些原则的一些合理解释开始。特别是:

http://en.wikipedia.org/wiki/Open_Closed_Principle [< a href =http://en.wikipedia.org/wiki/Open_Closed_Principletarget =_ blanktitle =New Window> ^ ],

http://en.wikipedia.org/wiki/Dependency_inversion_principle [ ^ ]。



参见: http://en.wikipedia.org/wiki/SOLID_%28object-oriented_design%29 [ ^ ]。



在专门为您编写的快速答案中解释任何内容在这里都没有多大意义。为什么它会比现有文献更好?



-SA
This is because you are reading wrong articles.

They are all based on wrong, or counter-productive formulation of the artificial problems. First one tries to "find" one or another principle in quite a pointless piece of code doing who-knows-what, other "focus" on "vs" or "difference". Those "vs" and "difference" are undefinable and carry no real meaning, and questions in such terms are incorrect.

Instead, you may need just to understand each of the two principles, their applications and value. And you probably need to start with some reasonable explanation of these principles. In particular:
http://en.wikipedia.org/wiki/Open_Closed_Principle[^],
http://en.wikipedia.org/wiki/Dependency_inversion_principle[^].

See also: http://en.wikipedia.org/wiki/SOLID_%28object-oriented_design%29[^].

Explaining anything in a Quick Answer written specially for you would not make much sense here. Why would it be better than available literature?

—SA


这篇关于Open Close vs Dependency Inversion Principal的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆