官术网_书友最值得收藏!

Chapter 1. Architecture of a Backbone application

One of the best things about Backbone is the freedom to build applications with the libraries of your choice, no batteries included. Note that Backbone is not a framework but a library; due to this, building applications with Backbone can be challenging as no structure is provided. You, as a developer, are responsible for code organization and how to wire the pieces of the code across the application; it's a big responsibility. Bad decisions can lead to buggy and unmaintainable applications that nobody wants to work with.

Code organization on small Backbone applications is not a big deal. Create a directory for models, collections, and views; put a router for all possible routes; and write the business logic directly in the views. However, this way of developing Backbone applications is not suitable for bigger projects. There should be a better way to separate responsibilities and file organization in order to create maintainable applications.

This chapter can be difficult to understand if you don't know Backbone at all; to understand the principles that are exposed here better, you will need to understand at least the basics of Backbone. Therefore, if you are a beginner in Backbone, I would encourage you to first understand what Backbone is and how it works.

The goal of this chapter is to explore the best practices of project organization on two main levels: logic organization and file structure. In this chapter, you will learn the following:

  • Delegating the right responsibilities to the objects provided by Backbone
  • Defining plain JavaScript objects in order to deal with logic out of scope of Backbone objects
  • Splitting the application in to small and maintainable scripts
  • Creating a clean file structure for your projects
主站蜘蛛池模板: 周宁县| 榆林市| 湖南省| 宁明县| 兰坪| 清河县| 军事| 华蓥市| 东阳市| 宁国市| 华蓥市| 永城市| 邛崃市| 定结县| 淳安县| 元江| 即墨市| 姜堰市| 会宁县| 万载县| 余姚市| 榆林市| 始兴县| 大埔区| 宜君县| 龙胜| 崇信县| 广安市| 上虞市| 云阳县| 高唐县| 樟树市| 勐海县| 金寨县| 永寿县| 勐海县| 河南省| 安化县| 岑巩县| 枣庄市| 鄄城县|