The Model-View-Controller pattern
It's always difficult to start a new project or the implementation of a new feature. We just don't know how to structure our code, what modules to write, and how they are going to communicate. In such cases, we often trust well-known practices—design patterns. Design patterns are reusable solutions to commonly occurring problems. For example, the Model-View-Controller pattern has proven to be one of the most effective patterns for web development due to its clear separation of the data, logic, and presentation layers. We will base our social network on a variation of this pattern. The traditional parts and their responsibilities are as follows:
- Model: The Model is the part that stores the data or the state. It triggers an update on the View once there is a change.
- View: The View is usually the part that the user can see. It is a direct representation of the data or the state of the Model.
- Controller: The user interacts with the help of the...