Placeholder Image

Subtitles section Play video

  • Over the last 20 years, websites have gone from simple HTML pages with a bit of CSS two incredibly complex applications, with thousands of developers working on them to make working with these complex Web applications much easier, developers use different patterns to lay out their projects to make the code less complex and easier to work with.

  • By far the most popular of these patterns is NBC, also known as Model of You Control.

  • The goal of this pattern is to split a large application into specific sections that all have their own purpose.

  • To illustrate each section, Let's look at an example where a user is requesting a specific page from a server based on what you are.

  • Oh, the user is requesting the server will send all the request information to a specific controller.

  • This controller is responsible for handling the entire request from the client, and we'll tell the rest of the server what to do with the request.

  • It acts as a middleman between the other two sections, model and view, and should not contain very much code.

  • The first thing that happens when a controller receives a request is it asked the model for information.

  • Based on the request, the model is responsible for handling all of the data logic of a request.

  • This means that the model interacts with the database and handles all validation, saving, updating, deleting and et cetera of the data.

  • The controller should never directly interact with the data logic and should only ever use the model to perform these interactions.

  • This means that the controller never has to worry about howto handle the data that it sent and received, and instead on Lee needs to tell the model what to do and respond based on what the model returns.

  • This also means the model never has to worry about handling user request and what to do on failure or success.

  • All of that is handled by the controller, and the model only cares about interacting with the data.

  • After the model sends its response back to the controller, the controller then needs to interact with the view to render the data to the user.

  • The view is only concerned with how to present the information that the controller sends it.

  • This means the view will be a template file that dynamically renders HTML Based on the data, the controller sends it.

  • The view does not worry about how to handle the final presentation of the data, but instead only cares about how to present it.

  • The view will send its final presentation back to the controller, and the controller will handle sending that presentation back to the user.

  • The important thing to note about this design is that the model and view never interact with each other.

  • Any interactions between the model and the view are done through the controller.

  • Everything controller between the model and the view means that the presentation of data and the logic of data are completely separated, which makes creating complex applications.

  • Much easier is all just theoretical, though.

  • Let's look at an example of how this design handles a request.

  • Imagine a user sends a request to a server to get a list of cats.

  • The server would send that request to the controller that handles cats by controller, would then ask the model that handles cats to return a list of all cats.

  • The model would queer the database for a list of all cats and the return that list back to the controller.

  • If the response back from the model was successful than the controller would ask the view associated with Cats to return a presentation of the list of cats.

  • This view would take the list of cats from the controller and render the list into H D Mo.

  • That could be used by the browser.

  • The controller would then take that presentation and return it back to the user, thus ending the request.

  • If, earlier the model returned in error instead of a list of cats, the controller would handle that error by asking the view that handles errors to render a presentation for that error.

  • That era presentation would then be returned to the user instead of the CAT list presentation.

  • As we conceive from that example, the model handles all of the data.

  • The view handles all of the presentation, and the controller just tells the model and view what to do.

  • And that's all there is to the basic architecture of NBC and then X video.

  • We're going to be doing all the basic set up for a library application and deploying to Iraq, so make sure to check out that video linked over here when it comes out.

  • Also, don't forget to subscribe to the channel to not miss any more videos in this Siri's thank you very much for watching and have a good day.

Over the last 20 years, websites have gone from simple HTML pages with a bit of CSS two incredibly complex applications, with thousands of developers working on them to make working with these complex Web applications much easier, developers use different patterns to lay out their projects to make the code less complex and easier to work with.

Subtitles and vocabulary

Click the word to look it up Click the word to find further inforamtion about it