Answers

Question and Answer:

  Home  Ruby Developer

⟩ Please explain what is MVC and why do we use it?

MVC stands for Model View Controller.

Model is the data structure that your program uses.

The View is the part that interacts with the screen or the next level up.

The Controller generally processes data between the model and view.

For example, a model will define your table in the database, the controller will dictate what to do behind the scenes and what to display in the view next. The view part generates the user interface which presents data to the user.

Let’s take an example of creating a form. The submit form will be a view file, from that view file, when you click on the submit button it goes to the respective controller where you have written your business code about what happens on submitting the application/form, and from that controller the data will be saved in the database.

Thus MVC helps to split up the the business logic, database access and presentation. This is very useful in most web applications, and now lately into software/desktop applications.

 124 views

More Questions for you: