Modularity in Software Engineering

What is Modularity

'Modularity' - a frequently used term in Software Engineering. Its often tends to feel that our Software System is modular owing to that of the physical and logical structure of the system.

We often distinguish interfaces and their implementations, abstracting the functionality behind the interfaces, grouping classes and interfaces under packages based on their functionality etc. Those techniques are really cool and they are the real drivers of modular software, but unfortunately modularity could not be achieved just by applying such techniques. Modularity is software engineering is based on few fundamental concepts.

Self-Contained : "Agile & Autonomous"

A module is a self-contained component of a larger software system. This doesn't mean that it is an atomic component. In fact a module consists a several smaller pieces which are collectively contributed to the functionality/performance of the module.

We cannot remove or modify at least any of these tiny (compared to larger software system) components and if we do so, the 'Module' will cease it expected functionality. A module can be installed, un-installed or moved as a whole(single unit) and it wont affect the functionality of the other modules.

Fig I - Modular Compartments


Lets try to understand this by above real world scenarios. In figure 1, we have a set of compartments that can mimic the modularity. Any of these compartments can be move without affecting other components' functionality (but when we move a module the functionality of the whole system changes).


Fig II - Modularizing ..

And also in the second figure we can form different letters by place different components(modules) at different places and we have the freedom of moving modules freely without affecting the functionality of other modules

Highly Cohesive : "To do one thing and do it well"

Cohesive is strong related to the 'responsibility' in real life. A responsibility is a kind of action that we identify that a given entity is subjected to act on.

'High Cohesiveness' means that a component (module) is strongly related or focussed to carryout a specific task and also not doing any unrelated tasks. Therefore, cohesive modules are fine-grained, robust, reusable and less in complexity.

In our compartment examples, you can see each compartment(module) contains a predefined set of sub components and they are responsible to carryout a well defined task and doing it with absolute efficiency.


Loose Coupling : "Hassle free interaction"

A given module's internal implementation is not dependent on the other module that it interacts with. Modules are interacting with a well defined clean interface and any of module can change its internal implementation without affecting other modules.

Its vital to define the interfaces between the modules with extreme care. In the ideal case an interface should be define based on the what a given module offers to other modules and what it requires from other modules.

So back to our real world scenario, in the compartment example, we can clearly see that the interfaces are well defined and any of the internal modification inside a compartment would not affect other modules.

Power of Modularity

Here is a concise explanation of Modularization benefits.

A well-defined segmentation of the project effort ensures system modularity. Each task forms a separate, distinct program module. At implementation time each module and its inputs and outputs are well-defined; there is no confusion in the intended interface with other system modules. At checkout time the integrity of the module is tested independently; there are few scheduling problems in synchronizing the completion of several tasks before checkout can begin. Finally, the system is maintained in modular fashion; system errors and deficiencies can be traced to specific system modules, thus limiting the scope of detailed error searching.

- Richard Gauthier and Stephen Ponto

Comentários

Postagens mais visitadas deste blog

Understanding Reactor Pattern with Java NIO

A new journey.. A new working place.. WSO2 Inc.