The persistence layer
Since we had a single product, we just instantiated it in the controller itself and displayed this product information on our web page successfully. However, a typical webstore contains thousands of products; all the information for these products is usually stored in a database. So, we need to make our ProductController class smart enough to load all the product information from the database into the model. However, if we write all the data retrieval logic in the ProductController class itself to retrieve product information from the database, our ProductController class will blow down into a big chunk of file. Logically speaking, data retrieval is not the duty of the controller because the controller is a presentation layer ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access