modularity in software engineering
Modularity is probably the single most important characteristics of a well-designed software system.
A system is modular if it composed or well-defined, conceptually simple and independent units interacting through well-defined interfaces.
- Modular systems are easier to understand and explain because their parts make sense and can stand on their own.
- Modular systems are to document because each part can be documented as an independent unit.
- Programming individual modules is easier because the programmer can focus on just one small, simple problem rather than a large complex problem.
- Testing and debugging individual modules is easier because they can be dealt with in isolation from the east of the program.
- Bugs are easier to isolate and understand, and they can be fixed without fear of introducing problems outside the module.
- Well composed modules are more reusable because they are more likely to comprise part of a solution to many problems. Also a good module should be easy to extract from one program and insert into another.
Module coupling is a way of characterizing good sub-program designs. The extent to which modules are independent is called Coupling. It is also called Intermodule Coupling. Ideally, interdependence amongst modules should be minimized.
Alternatively, coupling is a measure of the degree of independence between modules. When there is little interaction between two modules, the modules are described as loosely coupled. When there is a high degree of interaction the modules are described as tightly coupled.
The more dependent a module is on another, the more chances are there for error, because a mistake in one module may also cause unwanted or expected changes in another module that are dependent on it.
Although module coupling should be minimized, greater/lesser degrees of loose coupling will depend on the problem.
In good software systems, modules are kept as independent as possible.
Coupling is a property of a collection of modules.
For ex. in a word processing program.
- Modules implementing a graph type and a sentence type would inevitably be more strongly coupled than would modules implementing a word type and a printer interface.
- The former pair must rely on one another’s services for edits and formatting, while the latter have no intrinsic connection at all.
Engineering judgment must be brought to bear in determining whether the strength of loose coupling between two modules is appropriate.
Despite the desirability, in practice it is not always possible to minimize coupling. There are six different types of coupling.
Here, the modules are independent of each other and so are not really components of a single system.
- Data Coupling occurs when module passes non-global variables to another module.
- Modules are independent of each other.
- Can only communicate through passing data element or informational flags.
- The two modules has no need to know what goes inside the other module.
- Higher level module only needs to know what data to pass its subordinate.
- Subordinate module only needs to know what data it require and what data it will return.
- Stamp coupling occurs when module passes non-global data structure or entire structure to another module.
- Here, modules are more independent on each other
- Exposes modules to more data than they need
- A change in data structure will affect all modules that use it.
- The two modules must have some knowledge of the internal working of other modules that use the same data structure.
- It occurs when module passes control flags or switches to another module.
- The sending module must know a great deal about the inner working of the receiving module.
- The flag’s label must start with a verb.
- Common coupling occurs when modules refer to the same global data area or data structure.
- Modules that use the same area have quite high level of interdependence.
- This is undesirable as errors can spread throughout the system.
- Content coupling occurs when module directly refer to the inner working of another module.
- Module are highly interdependence.
- One module can alter data in other module or change a statement coded in other module.
Originally published at https://www.csmates.com.