Hey everybody what's going on this is Caleb with Debb slopes dot com.
And welcome to the intro to MBC in Iowa s target topic in this course.
We're going to be talking about model view controller which is a very very common design pattern in
software development but especially in Iowa.
Now there are plenty of other design patterns that currently exist and are currently being developed.
But model view controller is one of the core tenets of object oriented programming.
Now object oriented programming has been around since the 70s.
It's been around for a long time and because of that it is tested and true.
It is very reliable and very common.
Actually it's commonplace in most software development workplaces so if you know object oriented programming
if you know model view controller you're going to be good to go.
For the most part now that's not to say that model view controller is the best design pattern.
It's not to say it's the only one that will ever be around.
I think it will eventually be replaced.
But for the time being it's an excellent design pattern because it helps us to logically separate very
important parts of our application.
So we're going to begin by just sort of talking about the overarching theory of model view controller
and using some analogies and some examples to help you understand it.
And then we're going to put it right into practice by building an iOS app using Model View and controller
as a design pattern.
So to begin we're going to start with the model component.
Now for the model I want you to imagine a blueprint case to envision a blueprint in your mind.
Think about the purpose of a blueprint.
Think about what it does it tells how to make something.
It gives very important key information on how to build a certain device.
As you can see in this blueprint it includes lots of information.
There are some notes about how the device should be built.
There are some measurements there are you know size and shape.
There might even be some description of how things should look on certain blueprints.
Now the model component is very much like a blueprint.
It's going to basically tell how something should be built.
Now the model is going to store data.
So we're going to use the model layer to basically create blueprints for our different data types.
So for instance if I wanted to create a watch like this if I wanted to build a watch I would say all
right this watch needs to be rectangular in shape.
It needs to have two buttons.
It needs to have two slots for a strap needs to have a screen and needs to have a speaker.
It needs to have a heart rate sensor on the back.
And of course this is a very complex watch but watchmaking in general is pretty complex.
So I have then given instructions on how that watch should be built.
Then later a watchmaker could take that blueprint and they could actually follow those steps to build
a watch that anyone could use.
The model is very similar to a blueprint.
OK keep that in your mind.
Let's move on now to the view layer in software development the view layer basically tells how things
should look.
It's going to allow us to customize the appearance of the various elements on the screen it tells how
it should look.
Think of the view like the face of a watch when you look at the watch face there's a certain way it
should look you should be able to see the numbers that go around the watch so you know what hour it
is you should be able to see the watch hands the hour hand and the minute hand and you should be able
to see all of that.
Now the watch looks beautiful.
It looks amazing but what good is it if the numbers don't change if the hands don't move.
That is where the controller layer comes into place the controller.
As you may expect controls the view and in many instances it is actually called The View Controller.
Now the controller is like a watchmaker.
Think of it like that.
The controller communicates with both the model and The View and The View Controller basically controls
what the view does.
It controls how it changes and it takes the data from the model and it's going to pass it to The View
and display the changing data.
So imagine if I'm looking at my watch I have I'm looking at the.
So imagine I'm looking at the view of my watch there is maybe it's 320 p.m. If the minute were to increase
to 3:21 p.m. The controller would then say hey the model has changed let's update the view the view
controller is like the watchmaker winding a clock.
Cade the watchmaker might look at the time and then adjust the clock accordingly.
Or just the watch accordingly.
So the model is like a blueprint.
The view is like a watch face and the controller is like a watchmaker who's communicating between model
the data of our application and the view the watch face of our watch and it can react to those changes
in data and present it on the view.
So the model view and controller work together as a team they're very important in software development
and this is just basically kind of an overarching theory of how model view controller work together
to create amazing applications.
Now I know that some of this might be a little bit of theory.
It's a little out there but the analogy I believe holds true the model is a blueprint.
It tells us how we should construct a certain data type.
The view is like a watch face it customizes what we should be seeing.
And the controller is like a watchmaker who constructs the data types and passes the data to the view.
K. so we're going to move on now to the next video where we're going to go into a playground and we're
going to mess around a bit with model view controller and then by the end of this target topic you will
have built a small application that utilizes the principles of model view controller.
Awesome job guys.
Let's head over to the next video and let's do that now.