Modular programming

A module ( neuter, the module ) is a closed functional unit of software, consisting of a sequence of processing steps and data structures. Contents of a module is often a recurring calculation or processing of data, which must be carried out several times.

The use of modules corresponds to the principle of encapsulation ( encapsulation ); because:

  • The interface of a module defines only the data which requires / gives the module as an input and a result of processing.
  • The implementation contains the actual program code.

The processing method and the data remains hidden within the module (the principle of information hiding ).

Not to be confused is a module with a component, which is located a hierarchy level in functionality and summarizes functional modules to services here.

A module is called, for example, as a function or subroutine carries out a series of processing steps and delivers the result data back to the calling program. A module can even incorporate additional modules (and call ) - so a hierarchy of subroutine calls is possible. The specified modules in data structures and methods may optionally be inherited and inherited from other modules. Modules are therefore an essential element in the structured and object- oriented programming.

Application / use

Large, complex programs can be organized and structured through the use of modules. This can in many ways be beneficial (see also Modularity ):

  • The program logic is reusable, must be without redundant code created and maintained. Code repetitions are avoided.
  • Modules can be compiled separately in many programming languages ​​and provided in the form of program libraries.
  • Functionalities can be integrated on a modular basis and separately licensed for commercial applications.
  • Several developers (groups) can independently create and test individual modules.

Design and definition of modules and interfaces is part of the design phase of software development.

A distinction must be modules of the classes of object-oriented software development:

  • From classes copies can take the form of objects created ( instantiated ) are
  • Classes can inherit properties of other classes,
  • Polymorphism allows classes to change properties at runtime - relationships between modules are static.

The module concept was first published by David Parnas.

Many programming languages ​​support the module concept through integrated language tools, such as Ada, COBOL, D, F, Fortran, Haskell, Java, ML, Modula -2, Oberon and Component Pascal. In addition, scripting languages ​​such as Perl, Python, PHP and Ruby are mentioned.