CMPS 262: Advanced Programming
Introduction
When the scope of software projects increases it is important to divide the functionality into smaller building blocks, also known as modules. Usually modules are stored in separate files and provide an interface to interact with them and use their functionality. It is important that each module does not interfere with other parts of the software so variables and functions are usually defined locally and then exposed through the outside through an Application Programming Interface (API). While defining modules sounds easy enough, in practice it is challenging to divide larger tasks into smaller modules or components that than together achieve the set goals. This is because not only the modules have to work correctly, but also the interactions between them have to implemented correctly and this is usually not easy. Most of the time it also not obvious what the modules should be an experience plays an important role.
The main idea of a module is that it focuses on a clearly defined, specific task. By combining several modules it is possible to construct larger programs that achieve more complex goals. One commonly used approach is to define separate modules for Model, View, and Controller (MVC). The model maintains the state of the system, the view (or views) display aspects of the model, and controllers allow users to make changes to the model that are initiated from the user interface.
Module Objectives
- Explain the reason for using modules
- Describe the idea behind Model-View-Controller
- Implement your own modules
Learning Resources
- Reread implementation vs interface
- Read this beginner’s guide on JavaScript modules
- Read about Model-View-Controller
- Read this Martin Fowler article on Model-View-Controller
Learning Activities
- Readings
- Discussion Board
- Programming Project
For Further Study
- Read more about modules in this chapter of Eloquent JavaScript