In software engineering, a module (neuter, the module) is a component of a software system that is created during modularization , represents a functionally closed unit and provides a specific service.
Modules are characteristic of programming according to the programming paradigm of modular programming . Modules can contain further modules or constructs named with other names (such as function , procedure , class, etc.). In this way, the program functionality can be broken down into a hierarchy. Modules can inherit the data structures and methods specified in them or allow or forbid access to external modules.
In the various programming languages and development environments and their development over time, numerous different forms of implementation of modules (sometimes with different names) have developed. The term module is also often used synonymously with terms such as subroutine, procedure, subprogram , program part, program module.
As a storage object for program code , “module” is a typifying designation for the content in a program library , whereby a module is often a summary of thematically related procedures, functions, classes, constants and possibly other programming objects. Modules are also available for main programs ; they can alternatively represent different types of program code (such as source code , intermediate code , machine program ).
A module is to be distinguished from a component that is one level higher in the hierarchy and combines the (basic) functionalities of modules into (subject-specific) services. However, such components are sometimes also called “modules” in common usage (for example in SAP ).
Reasons for dividing programs into modules
For modular programming in general
- From the original view of assembler programming, the reason for the division was the multiple use of the same instruction sequence at different points in the program, thus saving memory space and avoiding code repetitions .
- In modern software engineering technologies, another important reason is the structuring of the software design : the source code of programs today consists of short and clear individual parts for the benefit of better maintainability , comprehensibility and troubleshooting (see modular programming ). Following this principle, self-contained sub-tasks (. Eg read routines, validity checks, complex calculations) are a structurally separate subroutines implemented (and possibly invoked at several points in the program code). Such “outsourcing” keeps the code clear; the computer-internal time and administrative expenditure for the calls is practically irrelevant on modern computing machines.
For stand-alone modules
- One aspect of software architecture is the creation of subroutines for use in multiple computer programs / applications. Certain technical or operational functions (for example a check digit calculation) can be used uniformly throughout the company.
- Modules can be created and compiled separately in different programming languages and made available for use in program libraries.
- Functionalities can optionally be integrated according to the modular principle .
- Individual components can be licensed separately for commercial applications .
- Several developers or developer groups can create and test parts of an application independently of one another .
- If required, independent modules can usually be changed independently of their calling programs (as long as their interface remains identical). This applies in particular to dynamically loadable modules.
Use / use
The use of modules with the principle of encapsulation ( encapsulation ); because:
- The interface of a module contains / names only the data (areas) that the module needs / delivers as input and result of the processing.
- The implementation contains the actual program code.
Outside of the module, the processing method and any module-specific data remain hidden (principle of information hiding ).
Large, complex programs can be broken down and structured through the use of modules. This can be useful in many ways (see also modularity ). For example, the size of the modules has an influence on the error density - it is lowest with a module size of 200 to 400 lines of code . The design and definition of modules and interfaces is part of the design phase in software development.
The module concept was first published by David Parnas .
Numerous programming languages support the module concept with integrated voice means such as Ada , COBOL , D , F, Fortran , Haskell , Java , ML , Modula-2 , Oberon , Component Pascal and PL / I . Script languages such as Perl , Python , PHP and Ruby should also be mentioned.
Examples of variants of modules
The following examples show that modules can have different technical characteristics:
Modules as structuring means in the source code
According to the principles of modular programming, modules are "logical sub-blocks" into which the task of a computer program is broken down. The module is often only defined as an individual code section in the source code , with OOP this can be a class . This code section / module can contain further modules or can be called as an independent, separately compiled subroutine .
Classes in object orientation
- Copies of classes can be created ( instantiated ) in the form of objects ,
- Classes can inherit properties to other classes,
- Polymorphism allows classes to change properties at runtime - relationships between other modules are usually static.
Object module (mainframe IBM world)
A compiler or an assembler creates a so-called object module from source text , the instructions of which are stored in a program library in the form of machine code . In order to be able to execute a program, its object code with the object code of all called subroutines is 'linked' with a so-called linker , whereby u. a. the entry addresses of the subroutines are used. The result is a loading module .
Loading module (mainframe IBM world)
Option A: Main programs and them (= static) added bound subprograms are a common executable program as a common, loading module <Main Program> 'in a program library facilities. From there they can be called using JCL calls (EXEC <Pgm>), for example.
Variant B: If subroutines are only to be loaded during the program run (= dynamic), a single 'load module <UPRO>' is generated from their object code, which is loaded by a load command in the calling (main) program via the operating system and then - as with statically bound modules - is called for processing.
Interaction of the calling and called program (part) in detail: See subprogram .
Modules in MS Access and VBA
The development environment MS Access understands “module” as a summary of all procedures or functions that have been created for an object, for example a form or a report in VBA . In such modules, further, subordinate sub-functions can be created and executed, for example "event procedures" with which an individual check is to be carried out when a certain data field is changed in a form. In addition, modules for globally valid data (e.g. 'GLOBAL DATA') or for globally addressable functions (e.g. 'GLOBAL CODE') can be created.
The term module at SAP
In the SAP software , individual applications are called “modules”. However, this corresponds to the software-technical module term only in the broadest sense, and is a summary of functionality on a business level that a user can optionally acquire and use.
- Duden, Volume 5, Foreign Dictionary, 7th revised and expanded edition, Mannheim 2001
- Gabler  definition module
- psion user-club OPL course part 4  because some of the modules (“synonymous: procedures, ...”) will be used again
- econstor.eu  page 19: ... to what extent a program is divided into sub-programs (modules), ...
- tse.de  SAP R3 modules
- Y. Malayia, J. Denton ,: modules size distribution and defect density. (pdf) In: 11th International Symposium on Software Reliability Engineering (ISSRE'00). October 2000, accessed August 1, 2018 .
- Microsoft creation of a VBA procedure functions in standard or class modules ( Memento from April 8, 2014 in the Internet Archive )
- SAP ERP What is ERP?  "Every application, i.e. every ERP module, is geared towards a business area."