{"id":16064,"date":"2020-07-10T06:18:58","date_gmt":"2020-07-10T06:18:58","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=16064"},"modified":"2020-07-10T06:29:04","modified_gmt":"2020-07-10T06:29:04","slug":"what-is-mvc-and-why-use-mvc","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/what-is-mvc-and-why-use-mvc\/","title":{"rendered":"What is MVC and Why use MVC?"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Model View Controller (MVC)<\/h2>\n\n\n\n<p>The MVC is an architecture pattern that separates an application into three main logical components <strong>Model<\/strong>, <strong>View<\/strong>, and <strong>Controller<\/strong>. Each of these components has its own role in a Project. <\/p>\n\n\n\n<p>MVC model was first introduced in 1987 in the Smalltalk programming language. More than 80% of all web app frameworks rely on the Model View Controller.<\/p>\n\n\n\n<p><strong>MVC Architecture<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"315\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/07\/mvc-artitecture.png\" alt=\"\" class=\"wp-image-16066\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/07\/mvc-artitecture.png 600w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/07\/mvc-artitecture-300x158.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/figure>\n\n\n\n<p>Now let&#8217;s describe below in brief.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Model<\/h2>\n\n\n\n<p>The model is responsible for getting data from a database, packaging it in data objects that can be understood by other components, and delivering those objects, most of which will happen in response to input from the controller.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">View<\/h2>\n\n\n\n<p>It represents how data should be presented to the application user. Users can read or write the data from view. Basically it is responsible for showing end-user content, we can say it is the user interface. It may consist of <strong>HTML<\/strong>, <strong>CSS<\/strong>, <strong>JS<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Controller<\/h2>\n\n\n\n<p>The user can send a request by interacting with the view, the controller handles these request and send to Model then get appropriate response from the Model, sends the response to View.<\/p>\n\n\n\n<p>It may also have required logics.<br>It works as a mediator between View and Model.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why use MVC<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Organized Code<\/li><li>Independent Block<\/li><li>Reduces the complexity of web applications.<\/li><li>Easy to Maintain.<\/li><li>Easy to modify.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Basic Structure<\/h2>\n\n\n\n<p class=\"has-text-align-left\">Assets<br>       &#8211; CSS<br>       &#8211; Images<br>        &#8211; JS<br>Config<br>       -Database Config File<br>Controllers<br>Model<br>Views<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Advantages<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Multiple developers can work simultaneously on the model, controller, and views.<\/li><li>MVC enables logical grouping of related actions on a controller together. The views for a specific model are also grouped together.<\/li><li>Models can have multiple views.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Disadvantages<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>The framework navigation can be complex because it introduces new layers of abstraction and requires users to adapt to the decomposition criteria of MVC.<\/li><li>Knowledge of multiple technologies becomes the norm. Developers using MVC need to be skilled in multiple technologies.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Popular MVC web frameworks<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Laravel<\/li><li>Ruby on Rails<\/li><li>Zend Framework<\/li><li>Django<\/li><li>CakePHP\u2026etc.<\/li><\/ul>\n\n\n\n<p><a href=\"https:\/\/www.guru99.com\/mvc-tutorial.html\" target=\"_blank\" aria-label=\"undefined (opens in a new tab)\" rel=\"noreferrer noopener\">For more information about MVC.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Model View Controller (MVC) The MVC is an architecture pattern that separates an application into three main logical components Model, View, and Controller. Each of these components&#8230; <\/p>\n","protected":false},"author":9,"featured_media":16069,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5201,1],"tags":[5457,4459,6211],"class_list":["post-16064","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","category-sql","tag-framework","tag-html","tag-mvc"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/16064","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=16064"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/16064\/revisions"}],"predecessor-version":[{"id":16070,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/16064\/revisions\/16070"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/16069"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=16064"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=16064"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=16064"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}