Modular programming is basically a strategy for reducing communication in a computer program, mainly through encapsulation.
Before modular programming, local code consistency was ensured by structured programming, but there wasnβt enough global consistency: if you decided that your spellchecker would be implemented as a red-black tree, then this implementation would be affected by everything else in the program, so the programmer working on , say, text rendering, will be able to access the red-black nodes of the tree to do important things with them.
Of course, this became hell when you needed to change the implementation of your dictionary, because then you would also have to fix the code of other programmers.
Worse, if the implementation details included global variables, then you had to be extremely careful who changed them and in what order, or strange errors occurred.
Modular programming applies encapsulation to all of this, separating the implementation (private from the module) from the interface (which the rest of the program can use). Thus, a dictionary module can display an abstract type, which will be accessible only through module functions, such as findWord(word,dictionary) . Someone who is working on a dictionary module should never look beyond this module to see if anyone can use implementation details.
source share