Software Design Principle
Separation of Software Design Principle in MVC:
- Model -> Data and Business Logic.
- View -> Visual Representation of Model.
- Controller -> Process Requests and Prepare Response.
Separating concerns also helps to make our website easier to maintain. With our improved design, if we wanted to create or retrieve our comic, we'd only need to change the central location of our project. It called Repository. This method sometimes called Repository Design Pattern.
Other software design principles:
- https://msdn.microsoft.com/en-us/library/ee658124.aspx
- https://en.wikipedia.org/wiki/SOLID_(object-oriented_design)
Let's do this:
- Right-click at project > Add > Folder > name with "Data".
- Right-click at data > Add > Class > name with "ComicBookRepository".
- Add a method called GetComicBook.
public ComicBook GetComicBook() { return null; }
- Go to controller class, then copy the comicBook variable. Move it into GetComicBook().
- Our implemetation so far have a major drawback, we could only display one comicbook. What we need is to display some of comicbooks. The idea is list all of the other comic books into array.