Pub Sub

An entire software application usually consists of several parts, called modules. Consider, for example, a web browser, which has a Tabs module, an Address Bar module, a Bookmarks module, and a Webpage View module (see Figure 15.6). To keep the code clean and organized, the modules should not have direct references to each other (in programmer-speak, the modules should not know about each other), because if two modules directly reference each other, they might as well be one module. If all the modules directly reference all the other modules, you end up with one giant module that is hard to maintain and nearly impossible to understand. Yet the different modules need to be able to communicate in some way. For instance, when a tab is selected, ...

Get Learning to Program now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.