Modules

The next development in programming languages was the introduction of an idea termed the module. (Called the unit in Pascal, name space in C++, various other names in different languages). Stripped to its most primitive form, the module simply provided the ability to encapsulate a collection of procedures and data values, and export only a limited number of those procedures or data areas.

So the writer of our stack abstraction would now hide the implementation data values, and only export the names push, pop and top.

Modules nicely solved the problem of encapsulation. But now there was another problem. What if your programming task required two or more stacks? The module facility by itself did not provide the ability to create multiple instances of a data type. So solving this required the next development in programming langauges.

[audio] [real] Text to accompany slide25, in Chapter 2 of An Introduction to Object-Oriented Programming