耦合和内聚 [英] Coupling and cohesion

查看:27
本文介绍了耦合和内聚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将耦合和内聚的概念归结为一个简洁的定义.有人能给我一个简短易懂的解释吗(比维基百科上的定义要短这里这里)?他们如何互动?

I'm trying to boil down the concepts of coupling and cohesion to a concise definition. Can someone give me a short and understandable explanation (shorter than the definitions on Wikipedia here and here)? How do they interact?

谢谢.

有人有一个很好的简短例子吗?

Anybody have a good, short example?

推荐答案

耦合

  • Loose:你和便利店的那个人.您通过明确定义的协议进行沟通以实现各自的目标 - 您付钱,他让您带着 Cheetos 的袋子走出去.可以在不中断系统的情况下更换你们中的任何一个.

  • Loose: You and the guy at the convenience store. You communicate through a well-defined protocol to achieve your respective goals - you pay money, he lets you walk out with the bag of Cheetos. Either one of you can be replaced without disrupting the system.

亲密:你和你的妻子.

凝聚力

  • 低:便利店.从汽油到牛奶再到 ATM 银行业务,您都可以去那里购买.产品和服务几乎没有共同点,将它们集中在一个地方的便利性可能不足以抵消由此导致的成本增加和质量下降.

  • Low: The convenience store. You go there for everything from gas to milk to ATM banking. Products and services have little in common, and the convenience of having them all in one place may not be enough to offset the resulting increase in cost and decrease in quality.

高:奶酪店.他们卖奶酪.没有其他的.但是,当谈到奶酪时,他们无法击败他们.

High: The cheese store. They sell cheese. Nothing else. Can't beat 'em when it comes to cheese though.

这篇关于耦合和内聚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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