开发者

Communication cohesion

There are coupling and cohesion for modules. OK. There are functional and communication cohesion. Functional cohesion is grouping by functionality. OK. Communication cohesion is grouping by input/output data.. Hm.. Not OK. Can any expl开发者_JAVA技巧ain me what is communication cohesion or/and provide example (any language, but Java is preferable)?


First of, it's called Communicational Cohesion.

I found the following explanation clear:

A communicationally cohesive module is one which performs several functions on the same input or output data. For example, obtain author, title, or price of book from bibliographic record, based on a passed flag. (Note: The functions in this example could be performed independently of each other and should be separated for greater flexibility. Maintainability is usually improved when you separate a communicationally cohesive module into functionally cohesive modules.)

For a comparison with the other types of cohesion, the referenced article seems really clear.

As the example states, it's important to prefer functional cohesion (or even sequential cohesion) over communicational cohesion.

Communicational cohesion is rare in object-oriented systems since object-oriented designs tend to stress polymorphism.


This is just my interpretation, but I'd say that "communication cohesion" means that code that works with the same data is placed together, and together with that data. "Together" can mean that it's in the same package or JAR, which means the advantage is mainly in maintainability. Or it can mean that it lives on the same hardware or the same LAN, which has performance and security benefits.


Presumably communication cohesion involves the use of open standard protocols and formats. e.g. HTTP, JSON, etc.

ETA: Wikipedia says:

Communicational cohesion is when parts of a module are grouped because they operate on the same data (e.g. a module which operates on the same record of information).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜