(Previous: (1.4.3) Module)

So, the concept of modules was born to limit the interaction between source code. The programming language Modula is designed by Niklaus Wirth (*1) around 1975. This language was based on Pascal and introduced the concept of modules.

In Modula, the module was a group of strongly related codes. We can not access the components in the module from outside the module without explicitly “exporting.” We can not access the components outside of the module from inside the module without explicit “importing”. In other words, the module in the programming language shows only a part of its contents outside and does not show the rest.

image

What you show outside is an important part to use that module as a component of programs. Consider, for example, a component “list” that can contain any number of values. To use it, you need functions such as “add one value to the list” and “get the N-th value of the list.” So those functions should be exported. On the other hand, the specific implementation details, such as how we store the values in memory, are not important for the user of this module. So we can hide them.

Related: Mediator Pattern

en.icon --- This page is auto-translated from [/nishio/(1.4.3.1) Restrict interaction](https://scrapbox.io/nishio/(1.4.3.1) Restrict interaction) using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at [@nishio_en](https://twitter.com/nishio_en). I'm very happy to spread my thought to non-Japanese readers.