Summary
In this chapter, we created an entire toy MVC system and proved that it works through the use of some automated testing. Rather than follow the order of naming in MVC, we started by looking at the Controller layer, and we implemented a front controller that handles dispatching requests to the correct controller.
Next, we built our Model layer. For the purposes of the toy, we are using hard-coded data and not using any kind of persistence layer. In real life, you would never do this and instead would expect to be interacting with some form of persistence (most usually a database). We looked at the Entity, Repository, and Collection patterns. We were using a UUID for IDs, which is definitely something I would encourage you to consider as a much better ID than simple integer IDs and relying on database autoincrement values.
Next, we built our View layer. We used a DTO to handle storing and sharing template data – this keeps our View layer nicely decoupled from the...