× Terms of Use Privacy Policy

Take me back!! I want my CSS!! Click me to get back :)

×

READY FOR A NEW CAREER?

But not sure where to start? Find out if a tech career is right for you.

TAKE THE 3-MINUTE QUIZ

MVC

MVC stands for Model-View-Controller and it’s the most popular way to organize and separate the different functions of a web application.

MVC stands for Model-View-Controller and it’s the most popular way to organize and separate the different functions of a web application.

In MVC you have three parts of your app, each of which serves a different function.

First, you have to define what each part of the web app is and how the different parts will work together. The Model defines what data you will have in your app, the relationships between that data, and how you will use it.

For example, if your web app is a blog, the Model says that there are blog posts and users, and defines the relationship between the two (users write blog posts).

Second, the View defines what the app looks like. In the View you define what is on each page and style it up fancy so that people love to visit your website!

Third, you have to connect the Model and the View together. It’s all well and good to let your Model define your data, and your View to determine how that data looks,  but without the Controller never shall the twain meet.

The Controller tells the View about all the parts defined in the Model (blog posts and users), it connects the View and the Model to the database, and ferries information between all three. And every time the user does something (like writing a new blog post) the controller lets everyone know.

The goal of MVC is to separate the app logic, from the app database, and the app look so your app code is nice and tidy and easy to edit. MVC is the organizing principle used by most PHP frameworks, Ruby on Rails, DJango, and many many others.

Cocktail Party Fact

Traditionally, Models, Controllers, and their good friends the databases, made up the backend of a web application. The Views, on the other hand, made up the frontend.

New JavaScript frameworks like Backbone.js are changing all that. What Backbone.js does is let you define a Model-View-Controller for your web app in JavaScript meaning the whole sha-bang can run on the client-side, no server necessary. You can read all about JavaScript MVC frameworks here.

Your email address will not be published.

0 comments

Want more articles like this?

Sign up to get the most recent tech news, tips and career advice.