哪种设计支持低耦合?
哪种设计支持整体低耦合?为什么?
Which Design supports overall low coupling? and why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
哪种设计支持整体低耦合?为什么?
Which Design supports overall low coupling? and why?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
在第一个中,付款与销售相结合。在第二个中,它与注册和销售相结合。我想说第一个耦合度较低,因为 Register 没有支付的概念。付款可以完全消除,并且不需要对注册进行任何更改。在第二种情况下,如果您取消了“付款”,则“注册”和“销售”都需要更改。
In the first one payment is coupled to Sale. In the second one its coupled to Register and Sale. I would say the first has lower coupling because Register has no concept of payment. Payment could completely eliminated completely and would require no changes to Register. In the second if you eliminated Payment both Register and Sale would need to change.
在第一个中,
Payment
由Sale
创建,因此耦合性更强。第二个与依赖注入的耦合度较低 - http://en.wikipedia.org/wiki/Dependency_injection< /a> ,witch 是一种设计模式,它将行为与依赖解析分离,从而解耦高度依赖的组件。在第一张图片中,
Payment
和Sale
高度依赖。In first one
Payment
is created bySale
so this is more coupled.in second one there is low coupling with dependency injection - http://en.wikipedia.org/wiki/Dependency_injection , witch is a design pattern that separates behavior from dependency resolution, thus decoupling highly dependent components.
Payment
andSale
were highly dependent in first picture.我不明白第一个例子的要点。不需要注册吗?
在第二个示例中,可以使用任何类型的付款。 (签证、现金等)。因此它的耦合更加松散。
I don't see the point in the first example. Register is not needed?
In the second example any kind of payment can be used. (Visa, cash etc). Hence it's more loosely coupled.