Modularization in Software Engineering
One year ago, when a friend and I were working on one of our first software engineering projects, we wrote the whole program in one singular file. There was no separation, no modularization, only one file with 2000+ lines of code. That inevitably led to countless merge conflicts, and changing one part of the code would almost always affect another part. We would often be changing a lot of old code just to add a new function.
In short, working on it was a headache.
What is modularization?

In this current age of software, you would be hard-pressed to find a program that isn't continuously growing and evolving. Designing a program all at once, with all required functions, would be difficult due to its size, complexity and constant changes. This is where modularization comes in.
Modularization is the process of separating the functionality of a program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of the desired functionality.

With modularization, we can easily work on adding separate and smaller modules to a program without being hindered by the complexity of its other functions. In short, it’s about being flexible and fast in adding more software functions to a program. In a software engineering team, we could easily work independently on each module without affecting others’ work.
It is the backbone of the microservice architecture, whose basic idea is also the simplicity of developing applications that are easier to extend and maintain when disassembled into small and independent parts. On the other hand, in monolithic architecture, there’s always the risk of bringing down the whole program with a simple update.

Without modularization, this will lead to an increase in development time, the number of bugs and the duration it takes to test and release a program.

Benefits of modularization
Why should we be decomposing our projects into modules? As shown in my experience with a single-file program, programs without proper modularization would be a nightmare to maintain and extend.
In modularization, the modules have minimal dependency on other modules. So, we can easily make changes in a module without affecting other parts of the program.
The following are just the gist of how modularization would improve the development process for a program.
- Easier to add and maintain smaller components
- Easier to understand each module and their purpose
- Easier to reuse and refactor modules
- Better abstraction between modules
- Saves time needed to develop, debug, test and deploy a program
How should we decompose modules?
A module should have only a single responsibility, that is the Single Responsibility Principle. Thus, it should depend minimally on other modules. The independence of a module can be measured using coupling and cohesion.
Coupling: Coupling is the measure of the degree of interdependence between the modules. A good software will have low coupling.
Cohesion: Cohesion is a measure of the degree to which the elements of the module are functionally related. It is the degree to which all elements directed towards performing a single task are contained in the component. Basically, cohesion is the internal glue that keeps the module together. A good software design will have high cohesion.


Each module should have a clear and focused purpose, such that its developers have a clear idea of the requirement for each function. Its interface should be easy to understand and use, even without understanding its implementation details. Thus, leading into our next point, is that its implementation details, while not only correct, should be encapsulated and private, and that it should be changeable without affecting another module. Furthermore, the dependency between modules should be minimised.
Example: Modularization on a text-to-speech application
Consider a text-to-speech application that will translate a user’s input text into speech and read it out loud. It should be able to:
- Parse a user’s input text
- Use a selected computer’s voice to read out the text
- Have a controllers that can speed up or slow down the computer’s speech if the user chooses
We can apply modularization to this application and decompose it to the following modules:
- Text-to-speech: Parses the user’s text to be read out loud
- Computer voice: Stores and provides computer voices that the user can choose
- Text speech controller: Controls that speed of the speech that the user chooses

Rather than designing the application as one giant monolith, it can instead be broken down into modules, each specific for one software function. Thus, the developers can develop each module in parallel, saving development time.
Additionally, the text-to-speech and computer voice modules can be used for other applications, for example a voice navigation application.

Therefore, the benefits of designing the text-to-speech application using modularization is that each module is responsible for its own independant function, which makes it easier to develop, test and maintain. Plus, they can be reused in other applications.
Conclusion
To sum it up, modularization is essential while working in a software engineering team, maximizing developer productivity. The complexity of a program can easily scale exponentially as it grows, which is the crux of developer productivity.
Modularization helps us break down large, complex systems into small and manageable components. Without it, it would be difficult to handle any but the smallest programs.
The power of modularization lies in its ability in allowing code to remain flexible when facing ever-changing requirements. Thus, we should always decompose our programs into modules so that we can fully enjoy the benefits of modularization.
Further Reading
The following link is a practical example of how we can apply modularization to a React-Redux application:
References
- https://www.geeksforgeeks.org/effective-modular-design-in-software-engineering/
- https://www.modularmanagement.com/blog/software-modularity
- https://www.geeksforgeeks.org/software-engineering-coupling-and-cohesion/
- https://www.genui.com/resources/5-essential-elements-of-modular-software-design
- https://www.infanion.com/news-blogs/modular-programming-increased-value-our-customers
- https://thecustomizewindows.com/2020/12/what-is-modular-programming/
- https://www.janeve.me/software-programming/modular-programming-in-java
- https://help.liferay.com/hc/en-us/articles/360018168431-The-Benefits-of-Modularity