What Are Modules In Programming?

Modular programming, Structured programming, and Object-Oriented programming do work on the same programming paradigm? Read this article till the end.

Introduction

The System Development Life Cycle is used to develop software. Using system development life cycle software is developed using a well-defined plan, the developed software is tested and deployed as per the defined strategies.

The software is developed to cater to multiple requirements. For each requirement, a program is developed. An example of software that caters to multiple needs is banking software. The banking software automates banking procedures. The banking procedures are many, and few of the procedures are independent, and few of them are dependent. For each independent procedure, a separate module is created. For each dependent procedure, a dependent module is created.

Another example of software that has multiple procedures is the software that is used in the retail sector. The retail sector software is developed to cater to multiple needs of the retail sector. For each need, a program is developed.

To develop a well-defined software System Development Life Cycle is used. The phase of system development software includes Planning, Analysis, Design, Implementation, and Maintenance. 

The software development begins with the planning phase. In the planning phase, activities are decided that needs to be programmed to achieve the desired objectives. Thus, planning is the most basic component to develop a well-defined software. The software planning is based on the logic that is used to develop the desired software. For example, the planning is based on forecasting, which visualises the end software product. Planning is done to achieve progress, efficiency, and effectiveness. 

In the analysis phase of software development, the complexity of the software is broken down into granular parts, and each granular part has its importance. The breaking of complexity into granular parts is used in mathematics and logic.

Analysis in software development is done to find the components that will make up the software. Then, an analysis is done to find the interdependency between components. Finally, further analysis is done to work on the techniques used to make the identified components independents. To conduct an effective analysis matrix should be developed.

Two types of analysis are done to develop software. These include Qualitative Analysis and Quantitative Analysis. Qualitative analysis is done to find the components that will be used to develop software. Quantitative analysis is done to find the number of individual components in the software to be developed.

The next step in developing the software is software Design. The software design is related to planning. First, the plan is developed to create software. Developing software without planning is also a software design. Next, the software design is developed to identify the constraint used to develop the software and constraints that will hinder the development. The software constraints decide the aesthetic aspect of the software, decide the functional aspect of the software, the software design also decides the financial aspect of the software, and software design also decides the interactions within the software and outside of the software.       

The major aspect of software design is to develop a software framework that will be used to develop the software. Thus, in software design, flow diagrams, interaction design, UML diagrams are created.  Business logic is also a part of software design. The components that interact with each other will be represented diagrammatically, and standalone components are also represented diagrammatically. Further, software design is created that projects the interactive and non-interactive components.

The last phase in the software development process is implementation. The implementation phase decides the execution plan of the developed software. The implementation phase also decides the idea conception to the desired software. Finally, the implementation phase decides the conceptual model that will be used to develop the desired software. The conceptual model is used to know the software to be developed, understand the software to be developed or decide the technique used to simulate the software. The conceptual model will also be used to analyse the concepts used to develop the software.

The conceptual design of the software will also be used to generalize the software development process. The generalization is an abstraction used to project the common characteristics of the components to be developed in the desired software. For example, generalization is used to develop the software by conducting deductive inferences. 

Generalization is also used to identify the components. Although the identified components can be independent and dependent, generalisation can project the underlying interconnectivity. Thus generalisation is used to establish the relationship that exists between components.

Identification of relationships in generalization is critical as it will form the basis to break the software into components and rejoin the components to build the full software. However, this process is not possible until an underlying relationship between the components is identified.

If two components, Component -1 and Component-2, are related, then in generalization, it is said that Component-1 is a “generalization” of Component-2 if all the objects of Component-2 are also objects of component-1 further there exists objects that belong to component – 1 and does not belong to component-2.

Specialization is the opposite of generalization. Instead, specialization is used to create specialised components from existing components. Thus, it can be said the child components are more specialized than parent components.

Refactoring

To reduce the complexity of the developed software, refactoring is done. However, the refactoring must not change the functionality of the software. Instead, Refactoring improves the software’s internal structure, which is reflected in the external functionality of the developed software.

Refactoring must improve the overall design of the software and reduce the degree of redundancy, flaws in the algorithm, and ineffectiveness of the data structures to be used in the desired software.

Refactoring helps in integrating the software components, improves the testing and maintenance process of the developed software. 

Structured Partitioning        

When the software design is based on the hierarchical structure, the architecture of the desired software is broken down either horizontally or vertically. In the case of horizontal partitioning, the control modules are used. These control modules maintain inter-function communication and are responsible for executing functions. 

Structural partitioning has three major benefits. First, it improves the testing and maintenance of the desired software, second, changes made in one module remain isolated in one module and do not influence other modules, third, it improves the extensibility of the developed software.

The desired functionality is spread over the entire modules using the top-down approach when software is developed using vertical partitioning—the top-level modules act as decision-makers, and the modules at the low level act as worker modules. The calling is made from the top-level modules to the low-level modules. The low-level modules are responsible for making all the computations the perform the input/output of the desired software.

Modular Design

The modular design is used to reduce the interconnection that exists between modules. In modular programming, all independent and dependent modules in the executable state build the desired software.      

The modularity in the desired software is decided by the language used to develop the desired software. Thus the language to develop the desired software must be such that it supports interfaces and information hiding.

The modules in the desired software must be functionally independent. Modules must support abstraction and the concept of hiding information. All the modules in the desired software must be represented using Data Flow Diagram. Further, coupling and cohesion between modules must be maintained.

A good software design supports low inter-module coupling and high inter-module cohesion. Thus to develop a robust software, it should be balanced on the platform of coupling and cohesion.

Coupling

Coupling is the term given to the depth of interconnection that exists between modules. Low coupling is desired in software modules. To achieve independence between modules, low coupling must exist between modules.

Interdependency between modules depends on the amount of information that is exchanged between modules. The higher the exchange of information between modules higher the degree of coupling between modules. 

To measure the degree of coupling between modules their exits no scientific methods. To overcome this, coupling between two modules were classified. The classification helps in quantitatively estimating the degree of coupling that exists between modules.

The different types of coupling between modules are – Data Coupling, Stamp Coupling, Control Coupling, External Coupling, Common Coupling, and Content Coupling. Among these, Data Coupling is considered best, and Content Coupling is considered worst.

Two modules are said to be Data Coupled if they exchange information using parameters. The two modules are said to be stamp coupled if they exchange information between modules using composite data. The Stamp coupling is done using structure in C language and records in PASCAL language

A Control Coupling is defined if another module dictates the order of execution of programming instructions. Example coupling module is when a variable’s value in one module is used in another module, and variable value decides further execution in that module.

Two modules are said to be externally coupled if they comply with the data format that is externally imposed. 

The two modules are commonly coupled if the two modules can interact with each other using a global variable.

The two modules are said to be coupled using content if they share the same code.

Cohesion     

The problem for which the software needs to be developed must be broken down into modules. These modules must be arranged into a hierarchy. The modules of the software must be high in cohesion and low in coupling. A module is said to have high cohesion if it is functionally independent. If each module does a single task, then it is said to be functionally independent.  A functionally independent module does minimum interaction with other modules in the software.

There exists other type’s cohesion. These are – functional cohesion, sequential cohesion, communication cohesion, procedural cohesion, temporal cohesion, logical cohesion, and coincidental cohesion.

Coincidental cohesion executes loosely related tasks. For example, a module has logical cohesion if the module contains elements that are capable of performing the same types of operations. A module also has temporal cohesion if the execution of functions within the module depends on a particular time. A module has procedural cohesion if the objective of the module is achieved by executing an algorithm. A module has procedural cohesion if the module works on the same data structure. A module has sequential cohesion if the module has an input-output sequence. Finally, a module has functional cohesion if all the elements of the modules work in the direction to achieve a single objective.

Software Design to achieve Modularity

The use of software design decides modules in the software. Therefore, different design methodologies are used to develop the software. These design methodologies include first, Function Oriented Design, and Second, Object-Oriented Design.

In function-oriented design, the software is viewed as a group of related, independent and dependent functions. In this design process, software development begins with the top-most function and is then refined as the functionality increases. As a result, the state of the system is global and accessed by required functions.

In Object-Oriented Design, the software is developed using multiple objects. The objects in Object-Oriented Design maintain information of their state. Each object is independent of the other it means that an object can not refer to or change data of other objects. Each Object has a state defined by its data. The same type of object belongs to a class. Each object in the software belongs to some class. The objects can communicate with others by the use of message passing techniques.

Object-Oriented design is used to model real-world entities. In Object-Oriented Design, objects maintain the state of the system. 

Structured Design

The structured design transforms the structured analysis into its respective structured design. For example, the structure design’s Data Flow Diagram is converted into a structured chart using transform analysis and transaction analysis.

Each Data Flow Diagram is converted into its respective module with the help of transform analysis or transaction analysis. To develop the structured design, different types of data flow is established, switch points are determined. Then, map the Data Flow Diagram to a specific program structure. When this done control structure is decided, this is decided by “first-level” factoring. After this second level, factoring is done in this Input/Output flow of data is maintained.

Structure Charting

In structure charting, software architecture is developed. The software architecture decides the module structure of the program. The module structure decides the module dependency, and the parameters are decided that are passed from one module to another module. The main objective of the software charting is to develop a module structure to be used to develop the desired software. The software charting also decides the interaction between different modules. 

A software chart is developed using rectangular boxes, arrows that invoc modules, arrows that denote the flow of data, libraries of modules, the diamond symbol to represent selection, and a loop to represent repetition.

Conclusion

A module is a component that builds the software, the modules can be independent, dependent, or modules interact with each other. The software can contain many modules, and each module is capable of performing a particular functionality. 

Using modules software development task is more logical as a programmer has to maintain logical coherence between modules, and it is assured each module do one task. So modules are used with the help of interfaces.

A software is developed to accomplish different tasks that are cohesively interrelated with others. As a result, the modules in the software can be reused. Each module in the software conducts a business or routine operation. 

A most cited example of module programming is Microsoft Word. 

Using modules functionality of the software is maintained, and each module is capable of achieving particular functionality. Modular programming is related to structured programming and Object-Oriented programming. All the three programming paradigms, Modular Programming, Structured Programming, and Object-Oriented Programming, have one objective to develop robust software. 

Modular programming is mostly related to procedural programming and is overrun by object-oriented programming. Therefore, C++ and Java are prefered over the C language. On the other hand, Python is a programming language capable of working with modules and objects.

Modules in programming are used in most programming languages and are now widely used. However, the critical importance of the module depends on the programming language in which it is developed.