松耦合的含义是什么 [英] What's the meaning of loose coupling

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

问题描述

松耦合

推荐答案

Loose coupling的含义是什么^ ].
Loose coupling is described here[^].


Nuri Ismail链接到维基百科文章 [
Nuri Ismail links to the Wikipedia article[^], which I think describes it fairly well. But if an analogy would help, think of going to a convenience store...

You walk into a convenience store, select the item you wish to buy, hand money to the clerk behind the counter, and walk out. Many other people perform this same action each day, and never have any other connection to the shop. The clerk may be replaced numerous times as well, without any significant change in how customers make their purchases. So long as both the clerk and the customer understand the relevant interfaces, they can interact effectively and efficiently without knowing anything else about one another.

Contrast this with the relationship between you and your employer: you may still interact through a large number of general-purpose interfaces, but it''s usually more effective if you both know something about one another beyond what''s explicitly stated in your contract.


耦合是指一类对另一类具有的直接知识程度.因此,松散耦合使少"知道另一类如何做某事.

通常首选松散耦合,因为如果A类与B类紧密耦合并且B类发生变化,则A类也将需要进行一些更改.

去耦(或松散耦合)可以通过使用简单的编程结构(例如接口等)来实现.
Coupling refers to the degree of direct knowledge that one class has of another. Loose coupling hence is knowing "less" about how the other class is doing something.

Loose coupling is generally preferred, because if class A is tightly coupled to class B and class B changes, class A would need some changes too.

Decoupling(or loose coupling) can be achieved by using simple programming constructs like interfaces etc.


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

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