The design that we will be aiming for by the end of this chapter can be summarized with this diagram:
We are beginning to divide the data layer into multiple components that will comprise the n-tier architecture – controllers, services, and repositories. While this diagram shows the full design, we will only be covering one tier at a time. In this recipe, we focused on the controller tier, which can communicate with the view layer via the PlanProvider interface.
To understand an n-tier architecture, it's helpful to think of your app as a cake. The topmost layer of the cake, where the icing and cherries are found, is known as the view. That's the first thing people see when they look at your cake.
Immediately underneath the view is where you put your controllers. For the purposes of this design, the job of the controllers is to process business logic. Business logic is defined as any rule in your app that is not related to presentation (view...