What is Model View Controller AKA MVC 🖥

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey did everyone this year back again with another video in this video I want to talk about something specific to the technical part and specially the coding part that is MVC Model View controller and I can understand I can understand your feeling that you might have watched a thousands of video might have read a lot of books about the design pattern and still you are confused about what is MVC or Model View controller now I have also seen those videos and I just cannot digest the thing that why do people are just making a presentation and that whole circle thing and just goes like that and puts out some of the definition and nobody understands that now what is the point of putting a definition from the book just in front of the people and people don't get the concept in itself so in this video I will try my best to make sure that you understand the concept of Model View controller as easily as it is possible now before we move ahead and talk about what actually is Model View controller let me let me walk you through that what basically the concept is now this is not a new concept first of all and it is a thing that you see in your daily life as well I'll prove that in example just in a moment and also this is not specific to one programming language it is a way of how you organize your code it is not like a specific thing for Ruby or PHP or for Java or for Swift it's just a way of how you organize your code and trust me you also see this kind of pattern every single day in your life and I can do a little bit better job in explaining what model-view-controller is so let's try that [Music] so yes you have seen model-view-controller probably a hundreds of time in your day-to-day life now let me try to explain what the model-view-controller is and where you see in your daily life so let's just see that this is you now you go to a restaurant and let's just assume this white entire animation kind of thing is a restaurant and you move on to a restaurant now what you do at a restaurant you don't just go to the kitchen and make a food by yourself you can do that at your home so what you wait you just go there and you wait for a waiter to come on now waiter comes to you and you just order the food to the waiter now waiter is not aware who you are or what you want to have it just gets that from you now whenever you sell the waiter that yes I want this the waiter just gets the order and now waiter moves to the kitchen now in the kitchen waiter is not going to prepare your food the food is prepared by the cook so let's bring up the cook now waiter will tell that the cook hey this is a guy out there and he wants this kind of food and now cook is the guy we're going to prepare the food for you but cook did not prepare the food magically he needs some ingredients to cook the food he'll open up the fridge and we'll put out something legitly you order an omelet so he'll get the egg sugar and whatever it needs so let's bring our fridge as well so now the fridge is there and cook will cook the food now cook will finally hand over the food to the waiter and probably the cook might hand over a couple of other foods as well like maybe a glass of soda or maybe my favorite icy or omelette that you have ordered now it's the job of the waiter to move those food outside the kitchen now waiter is actually aware that what kind of foods need to be served to you and how it should be served so waiters comes back to you and order and your order is now served so you might be wondering hey what this tool is all about and probably you might have anything guess that but this is all of your model-view-controller let me show you how that works on so this you guys is actually have you this waiter guy is actually the controller and yes you get that right this hood guy is model in itself and if you haven't guessed that yes the fridge guy is actually the data so how about that this is a cool example and this is kind of a thing you see every day you have been going to restaurant every day and they are following a model-view-controller objectives throughout the year so this is basically your model-view-controller now I can understand you have gone through with that restaurant example pretty easily and nicely now you want to understand how this is applied in the code now first of all a lot of people believe that model-view-controller is a thing for only dotnet or maybe only for Ruby or maybe hungry for PHP but it's not it's the design pattern it's the way how you arrange your code and it's going to be possible in everywhere you might want to write an application and PHP Swift java.net Ruby Python you can just arrange your code like that now the whole advantage of this approach is you can write dumb code and the more the code is going to be dumb it's going to be more beneficial what I mean by that now all I'm trying to say is we are trying to reduce the dependency of each code and this file in this file from each other we want that if some data is being passed on this file it just it just process this data it shouldn't be worried about from where this data is coming up ROM or there shouldn't be any dependencies between these codes it just needs the data fetching the data and that's it in our example we can see that our cook is not actually worried about who is ordering the food is it a male or female is it a kid or maybe a grandpa he doesn't really care he just gets the order and cooks the food and that is actually a dumb way of separating the people each other now this is a basic example and you will see this kind of thing quite a lot in my boot camps where I teach iOS or Android or wherever I does that I always recommend to use the model-view-controller approach but let me give you also an example that this kind of approach although is good in most places but in some places it can be opposite of that like for example if there is a store which just sells the popsicles or ice creams it would be really bad approach if we use model-view-controller there because there is just one job to do just bring up the ice cream from the fridge and serve it that's it if you use it if you will use the model-view-controller approach there it would be overused and overkill of the resources so at some point of that time model-view-controller is not a good approach but in most of the cases where application is pretty humongous pretty big then it's a good idea to use the model-view-controller approach now although we are not going into the in depth of what this model what is new what is controller because if I will be taking an example specifically for Android it would be really not a good thing for iOS if I will be taking an example directly from iOS it would not be a good approach for Android so all I'm doing here is trying to generalize the thing as much as possible now one thing I would like to mention that a lot of people misunderstood the thing that your model is not the data again I repeat your model is not the data the data is completely separate it needs to be cooked up so that is what the cook is doing in our example and in the real life example your data would be something fetching up from an API request or maybe from the firebase or wherever you guys fetching your data and your models should be the guy who should cook up these data should process the data and finally controller should be responsible from taking the data filtering the request and let us say you have asked for a result of maybe top 10 wonders of the world and there can be hundreds or hundreds of such wonders of the world now you are looking only for the ancient wonder of the world so it's the job of controller to filter out the data and just produce that on to the view and the job of the view is simply to arrange those data which is being passed on from the controller and that's it so this is a general approach that I tried to show you in this example and I think this is going to be one of the best movie on model-view-controller approach now I think I think that this video has cleared a lot of the concept about models air controller just want to summarize a game thing this is not a specific approach for dotnet or PHP or Java or Swift it's the generalized way of writing the code it's a generalized way to separate the data dependencies and again Model View controller is not always the good approach in most of the cases it is but for the small-scale application it can be sometimes overcook thing okay so with this this was the whole idea about the Model View controller and in case you are new to the channel make sure you do hit the subscribe we always come up these kinds of awesome content here and talk all about programming text web apps mobile apps and pretty much everything related to check so subscribe to the channel and hit the like button in case you liked the video also make sure you comment down below what kind of more such topic you would like to see on this channel and I'll surely catch you up in the next video
Info
Channel: Hitesh Choudhary
Views: 179,842
Rating: undefined out of 5
Keywords: Programming, computers, code, hacking, information, Security, iOS, iPhone, udemy, online-courses, coupons, free-coupons, udemy-coupons, udemy-courses, android, iphone, reactjs, web-development, MVC, Model View controller, MVC pattern, MVC code, ruby MVC, ios MVC, java MVC, android model view controller
Id: fa8eUcu30Lw
Channel Id: undefined
Length: 9min 13sec (553 seconds)
Published: Thu Jun 08 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.