Use of modules
The idea of modules is data hiding and locality. Place groups of related subroutines and data
together in one module. Common parts of the software architectures of the system are candidate
to be placed in modules.
Due to the availability of modules, common blocks are prohibited.
Explicit interfaces should be use. The interfaces are automatically known in the calling routines
by means of the USE statement. Two ways are possible:
- Place the whole subroutines in the module.
The drawback is, however, that a small change in a module procedure, even it is declared
private and the interfaces are not changed, can cause a cascade of compilations in all
the places where the module is used.
- Place only the interfaces in the module.
The drawback is that the interfaces appear twice: in the subroutine and in the module.
Both choices are allowed.
Make the interfaces of the subroutines explicit. Place several modules where the interfaces and subroutines
are programmed in the same file. Redefinition of functions is only allowed when a naming conflict
occures, otherwise redefinition of functions is prohibited.
All entities in a module must be declared private by default, and thereafter the entities are declared
public which have to be known outside the module. Modules may not contain data that is shared by
different subroutines of a program. Modules may contain private data.
The SWAN team 2022-08-10