Model
The Model represents the data and business logic for our app. In the toy MVC there is no real business logic, but in a full app, you would expect at least some form of CRUD functionality. In a real app, the Model is expected to be the most substantial aspect and certainly the bit that requires the most thorough testing, as in some regards it represents the true nature and purpose of the app itself.
In our toy, the Model is purely serving to retrieve data, but it is enough for us to introduce you to another design pattern, namely the Repository.
Entity pattern
An entity is a unit of data that represents a single thing. In the ubiquitous language of our application, the entity name will be meaningful and describe clearly what it represents.
For our toy MVC, we have two entity types:
- Category
- Post
The relationship between our entities is a one-to-many relation between Categories
and Posts
– meaning that Categories
are related to zero or more...