What is the MVC Architecture?
What is the MVC Architecture?
MVC Architecture is a pattern which every programmers love. Let’s here a great explanation of MVC architecture who are newbies.
MVC Architecture has three main components:
-Model
-View
-Controller
and each of them has specific responsibilities
The main reasons why MVC is used are: First, it doesn’t allow us to repeat ourselves and second, it helps to create a solid structure of our web applications.
Model
It is known as the lowest level which means it is responsible for maintaining data. Handle data logically so it basically deals with data. The model is actually connected to the database so anything you do with data. Adding or retrieving data is done in the model component. It responds to the controller requests because the controller never talks to the database by itself. The model talks to the database back and forth and then it gives the needed data to the controller. Note: the model never communicated with the view directly.
View
Data representation is done by the view component. It actually generates UI or user interface for the user. So at web applications when you think of the view component just think the Html/CSS part. Views are created by the data which is collected by the model component but these data aren’t taken directly but through the controller, so the view only speaks to the controller.
Controller
It’s known as the main man because the controller is the component that enables the interconnection between the views and the model so it acts as an intermediary. The controller doesn’t have to worry about handling data logic, it just tells the model what to do. After receiving data from the model it processes it and then it takes all that information it sends it to the view and explains how to represent to the user. Note: Views and models can not talk directly.
Advantages of MVC
– MVC architecture will separate the user interface from business logic and business logic
– Components are reusable.
– Easy o maintain.
– Different components of the application in MVC can be independently deployed and maintained.
– This architecture help to test components independently.
Disadvantages of MVC
-The complexity is high.
-Not suitable for small applications.
-The inefficiency of data access in view.
Conclusion
So MVC is not that easy to understand, it’s really hard actually, but not impossible to learn and every developer needs to keep it in mind when developing an application. Just keep in mind that MVC is an architecture that divides your software into smaller components. The model deals with data and the logic of your system. The view only displays data and the controller maintains the connection between the model and the view. This ‘division’ enables readability and modularity as well it easier the testing part.
very useful for me. Thank you
Very helpful for me. Thanks
Pretty useful