Software Engineering (2160701)

BE | Semester-6   Winter-2018 | 16-11-2018

Q4) (c)

Compare Coupling and Cohesion. Explain different types of Coupling and its effects on software modules.

Sr Cohesion Coupling
1 Cohesion is the indication of the relationship within module. Coupling is the indication of the relationships between modules
2 Cohesion shows the module’s relative functional strength. Coupling shows the relative independence among the modules.
3 Cohesion is Intra – Module Concept. Coupling is Inter -Module Concept.
4 While designing you should strive for high cohesion i.e. a cohesive component/ module focus on a single task While designing you should strive for low coupling i.e. dependency between modules should be less.
5 Cohesion is the kind of natural extension of data hiding for example, class having all members visible with a package having default visibility. Making private fields, private methods and non-public classes provides loose coupling.

Different type of Coupling

Data Coupling

  • If the dependency between the modules is based on the fact that they communicate by passing only data, then the modules are said to be data coupled.
  • In data coupling, the components are independent to each other and communicating through data. Module communications don’t contain tramp data. Example-customer billing system.

Stamp Coupling

  • In stamp coupling, the complete data structure is passed from one module to another module.
  • Therefore, it involves tramp data. It may be necessary due to efficiency factors- this choice made by the insightful designer, not a lazy programmer.

Control Coupling

  • If the modules communicate by passing control information, then they are said to be control coupled.
  • It can be bad if parameters indicate completely different behavior and good if parameters allow factoring and reuse of functionality.
  • Example- sort function that takes comparison function as an argument.

External Coupling

  • In external coupling, the modules depend on other modules, external to the software being developed or to a particular type of hardware.
  • Ex- protocol, external file, device format, etc.

Common Coupling

  • The modules have shared data such as global data structures.
  • The changes in global data mean tracing back to all modules which access that data to evaluate the effect of the change.
  • So it has got disadvantages like difficulty in reusing modules, reduced ability to control data accesses and reduced maintainability.

Content Coupling

  • In a content coupling, one module can modify the data of another module or control flow is passed from one module to the other module.
  • This is the worst form of coupling and should be avoided.