“Hello World” in MVC Pattern

后端 未结 5 1349
挽巷
挽巷 2021-01-29 19:18

In an interview for some company, I was asked this question.

What design patterns do you know...then I was told to write simplest \"hello world\" application based on MV

5条回答
  •  礼貌的吻别
    2021-01-29 19:42

    MVC is a design pattern that should be used to structure your application. MVC stands for Model, View, Control. It basically sais that you should separate your business-logic (Model) from your User Interface (View) and your Control-Logic.

    For example:

    You have a user class, that loads users from the database, can save em. This is your model.

    You have a Controller that uses the User class to log a user in.

    After the controller is done, it displays a Template containing the Text "Welcome $username".

    Also, the Model should not know about the View and the Controller, the View should not know about the Controller, whereas the Controller knows about the Model and the View.

    Wikipedia on MVC: http://de.wikipedia.org/wiki/Model_View_Controller

提交回复
热议问题