Step 2: Write the Model Code
Let’s take a look at how to set up the model class file for the web application.
In this step, we’ll write the code of our model class and save it in a specific model class file. In an MVC application, the model code is the most important part of the application. It’s also the basis for writing the view and controller code.
In fact, large parts of the view and controller code can be automatically generated from the model code. Many MVC frameworks provide this kind of code generation.
In the information design model shown in the previous lesson, there’s only one class, representing the object type Book
. This figure can be found below as well:
Get hands-on with 1400+ tech skills courses.