HoangLiarPhuongLe / javascript__training

0 stars 0 forks source link

WHY SHOULD WE USE MVC PATTERN ? #22

Open HoangLiarPhuongLe opened 1 year ago

HoangLiarPhuongLe commented 1 year ago

MVC Design Pattern stands for Model - View - Controller, this is a popular architecture for structuring many websites:

Model: This is the part that has the function of storing data and re-visualizing objects that will be used in the system

View: This is the user interface. Everything users see on the Website is the View

Controller: This is the part whose main function is to create a link between View and Model, in addition, it also has another function which is navigation

Processing flow of the MVC pattern:

  1. When a user sends a request, the Controller will be responsible for seeing if it is a URL request or what event it is
  2. The Controller will then process the input and then communicate with the Model
  3. The Model will prepare the data and send it back to the Controller
  4. Finally, the controller will send that data to the View and the View will display it to the user on the Website

Here are several reasons why the MVC pattern is commonly employed:

hungnguyenhuu-agilityio commented 1 year ago

Processing flow of the MVC pattern => About this one, the first thing is that, controller will responsible to show up the View (which UI need to show first). And for the next steps, user can interact with the UI which have rendered already (this is the step 1 you mention above). I think you miss step 0 that I mention. ^^

hungnguyenhuu-agilityio commented 1 year ago

Here are several reasons why the MVC pattern is commonly employed => You listed out almost of the benefit relate to MVC, but you may miss the important things that, MVC will make sure the security of your app. Imaging that, the user from View won't cover the code flow behind, they just see the result, it good for them and for your app data. MVC will make sure your data which showed to the user does not carry any sensitive information. Any strange actions from user will be reject from controller and it will not affect to your data also.

HoangLiarPhuongLe commented 1 year ago

@hungnguyenhuu-agilityio I have read your comments and understand them all. Thank you for your support and suggestion, it has helped me improve a lot and better understand the MVC pattern. Thank you again for your invaluable support and I hope you have a good day.