Join Kai Gittens for an in-depth discussion in this video What is Backbone?, part of Up and Running with Backbone.js.
With MVC, code is broken down into three separate components. The M stands for model which is a part of the code that contains the applications data. The V stands for view, which displays model data on whatever graphical user interface is available, like a computer screen. And the C stands for controller, which is the bridge between the model and the view. Its job is to transport model data over to the view. As we can see, MVC breaks code out into three distinctive parts, with each part having a distinct responsibility, a process commonly referred to as decoupling.
It's very easy to create one long file of sloppy code all mixed together in a huge mess. Which leads to not only inefficient, slow-performing code, but also code that's almost impossible for someone else to read and understand, if they need to make changes to it themselves. The decoupled MVC pattern helps us avoid all these problems and instead allows us to create a nice, tidy code base. Backbone is based on MVC, but it doesn't follow the strict definition we just discussed, and differs from traditional MVC in two important ways.
First, Backbone doesn't have a separated out controller component, like MVC does. It did in earlier versions, but not in the version that I'm using for this recording. For this version, the older controller functionality has been moved to other Backbone components. Speaking of components, this brings up the second difference that Backbone has from traditional MVC. Where MVC has three distinct decoupled components, Backbone has six. Backbone does use models to store data. So in this course we'll be creating a web application that stores data about a group of flowers.
Events like clicks and mouse overs. Backbone routers allow us to create a navigational structure within our web app, allowing us to create anchor tags that navigate to certain parts of our application. Backbone's router component is as close as you can get to a traditional MVC controller. It's actually where most of the old Backbone controller code we previously discussed has been moved to. Now Backbone sync is the last component. It's mostly used to help Backbone communicate with server side technologies like databases.
That's in the next movie.
- What is Backbone.js?
- Understanding how MVC libraries work
- Adding properties to a model
- Creating a collection of models
- Adding properties to a model view
- Loading model data on a web page
- Configuring routes
- Finding Backbone resources