Model View Controller (The basics of </>)
M V C
the basics of web development
Today we'll have a look at Model, View and Controller. We'll all know that web technologies are the ones trending these days, everyone want to shift to web rather then going mobile.
So let's see what is there in this fragment of web which keeps all the assiduous motivated to learn this and to make new developments in it.
Let us first have a look at what MVC is in laymen language.
Model: Model acts exactly as human brain, what it does is it keeps the business logic with in it and helps the application to implement what is required to make advancement in the service from business point of view.
View: View is similar to our skin, all the users i.e other humans see it, our view (lets say eyes) obtain data from external world and sends it to our brain i.e. the Model, but here lies the issue, Views are not meant to directly communicate with the Models, that brings the 'C' i.e Controllers into the picture.
Controllers: As per our present channel of communication, you can think of Controllers as our nerve sets which helps to transfer the message received by the view to the model, model then processes the information and reverts back to view via controller with the information which is the output of model.
So let's see what is there in this fragment of web which keeps all the assiduous motivated to learn this and to make new developments in it.
Let us first have a look at what MVC is in laymen language.
Model: Model acts exactly as human brain, what it does is it keeps the business logic with in it and helps the application to implement what is required to make advancement in the service from business point of view.
View: View is similar to our skin, all the users i.e other humans see it, our view (lets say eyes) obtain data from external world and sends it to our brain i.e. the Model, but here lies the issue, Views are not meant to directly communicate with the Models, that brings the 'C' i.e Controllers into the picture.
Controllers: As per our present channel of communication, you can think of Controllers as our nerve sets which helps to transfer the message received by the view to the model, model then processes the information and reverts back to view via controller with the information which is the output of model.
Example:
For the example we'll get our hands dirty in some technical stuff
Spoiler Alert:: Boring stuff Ahead
You want to create a login form which displays Dear 'username' after login.
(Let us assume user is already registered with the following details,
username: Blogger
password: Gmail@123
( Little jargon here)
)
Total files: 2+1+1 [ I guess that's 5 (please crosscheck once) ]
Views - 2
Controller - 1
Model - 1
Spoiler Alert:: Boring stuff Ahead
You want to create a login form which displays Dear 'username' after login.
(Let us assume user is already registered with the following details,
username: Blogger
password: Gmail@123
( Little jargon here)
)
Total files: 2+1+1 [ I guess that's 5 (please crosscheck once) ]
Views - 2
Controller - 1
Model - 1
(prerequisite: knowledge of universal selector)
View 1: v1.*
This is the home page which says welcome to 'Site ABC' and displays the login form
Controller 1: c1.*
This takes data from the login form and sends it to Model 1
Model 1: m1.*
This is the home page which says welcome to 'Site ABC' and displays the login form
Controller 1: c1.*
This takes data from the login form and sends it to Model 1
Model 1: m1.*
This is used to make the database connection and validate the user, here we'll assign a username variable which will be passed to the controller c1, no need to use 2nd controller for it.
View 1: v2.*
This will display Hello Blogger (if it has a valid entry else v1)
We can also do this via v1 but lets use one more view (keeping it simple ;-P )
Now you'll be thinking this is all conceptual (# ye toh pata h yarr, kuch aur bata ;-) )
So for that you got to wait for the next blog which will be uploaded really soon.
Spoiler: It' is going to be php-based (#Laravel)
View 1: v2.*
This will display Hello Blogger (if it has a valid entry else v1)
We can also do this via v1 but lets use one more view (keeping it simple ;-P )
Now you'll be thinking this is all conceptual (# ye toh pata h yarr, kuch aur bata ;-) )
So for that you got to wait for the next blog which will be uploaded really soon.
Spoiler: It' is going to be php-based (#Laravel)
Till then,
Adios Lactores
Happy Blogging
Adios Lactores
Happy Blogging
Hands of Ether Web Development
ReplyDeleteHands of Ether web development provide low-cost web development services online, Check our web developer portfolio and get the best web design services near me.
to get more - https://www.handsofether.com/