This project used Apache Maven as its build system, which contains a default directory structure. The structure seperates the main application in an folder called "main", from the tests located in "test".
The team chose to use MVC (Model, view, controller) structure for the main source code. This allowed for seperation of the logic into packages where they fit. At the same this, it resulted in reduction of complexity of the entire code structure, since the logic and display was seperated into three separate layers. It made sure that the coupling got looser between the three layers, making them more independent, and better code cohesion.
Here is a brief explanation of how these components interconnect.
Model: This is where the business logic and data reside. For example, “Grocery” encapsulates the data (like grocery items) and the operations that can be performed on this data (like adding or removing observers)
View: This is the user interface. It displays the data to the user and takes user input. View is responsible for creating the visual representation of a grocery item.
Controller: This is the intermediary between the model and the view. It takes user input from the view, processes it, and updates the model. Classes like “HomeController” and “PantryController” handle user interactions and update the model and view accordingly.
The interconnection works like this:
- The user interacts with the view (for example, checking a box next to a grocery item).
- The view sends this user action to the appropriate controller (like
ShoppingListController
). - The controller processes this input - it may update the model (like marking a
Grocery
item as checked) and then tell the view to update itself. - The view gets the updated data from the model and displays it to the user.