In modular programming, a standard practice is to define common interfaces allowing the same type of operation to be performed on a set of otherwise independent modules.
modules = [a,b,...]
for each m in modules:
To implement this pattern, two mechanisms are required:
- instantiation, to allow each module to define an 'instance' of the common interface,
- registration, to allow each module to 'provide' this instance to other modules.
Instantiation is typically supported natively in high-level languages.
Registration is more difficult and usually requires specific code to be written, or relying on external frameworks.
Let's see how these two mechanisms can be implemented for C programs.