Software Development Resources
Create account | Log in | Log in with OpenID | Help


From DocForge

Modularity is the concept of parts of a software application as semi-discrete components.

The general guiding principle of code modularity is that software is often best designed as distinct manageable components. This is in contrast to a monolithic architecture, where all logic is bundled together into one large component.

Modularity can be seen at many levels. Modularized source code can compile together into one executable. At a higher level, an executable can use shared libraries. At an even higher level, a system might delegate some functionality to other shared systems over a network.

[edit] Benefits

  • Code modularity lets programmers focus on specific sub-tasks within an application. For example, security experts can independently create a security module while a user interface module is being developed by others. This implies larger software development teams are able to work on one system when properly modularized.
  • Modularity helps separate responsibilities between software developers, teams, and even organizations. This is as much a benefit to the software development process as it is a technical benefit. This also helps larger teams work on one system.
  • After defining an interface, a module's implementation can later be changed without affecting users of the module. These changes can be bug fixes or security enhancements, improving maintainability of the system. These modular changes can also be feature enhancements, providing extensibility to the system. Modularity can therefore "future-proof" an application. Preparing a system for features or extensions it does not yet need is very efficient architectural design, although often very difficult to plan and implement.
  • Modularity is a primary solution for code reuse. Within one system multiple code segments my use a single module, eliminating the need to recreate the required functionality in each separate subsystem.

[edit] Implementation

Code modularity is partly dependent on programming language and runtime environment. With object oriented programming, for example, classes create a level of modularity. Some languages, such as Python, explicitly define modules and how they can be reused.

A critical feature of any module is its interface. Without a clear description, a module can't easily be used by other code. For example, a user account module needs a way to check user credentials, change passwords, etc. If well defined, the module can be reused in many different scenarios. Within one organization the module might be used by every custom desktop application to support consistent user accounts.

Also, a good interface won't need to be altered over time as functionality is added or changed. To continue the example, if a security flaw is found in a user account module, it's best if the flaw can be fixed internally without any change to the interface. No application using that module would then need to be changed as well. Also, if a new feature is added, such as password generation, an application can optionally use the new feature without current applications being altered.