addyosmani/backbone-fundamentals — pull request #307 by dcmaf (2013-02-02 22:20:56+00:00)
Title: Proposed changes to Chapter 3: Internals

@Addy - I've finished reviewing Chapter 3: Internals and checked in a bunch of changes (including a proposed new chapter title!). I've added a few new things and expanded on some of the existing discussion, so please check for accuracy.

I've also made recommendations below for moving some of the material at the end of the chapter to later in the book. I think that if I am a reader new to Backbone then what I want out of this chapter is just enough information to get me started and then to move on to the tutorials to solidify what I've learned so far. Thus, the less that is in this chapter, the simpler it will seem to the reader and the less daunting their experience will be.

Marc

Summary of Changes:

- Renamed chapter to Backbone Basics. 'Internals' to me conveyed implementation
details and sounded intimidating. Something along the lines of 'Basics',
'Essentials', or 'Core Backbone' sounds like I'm going to learn what I
need to know in order to use Backbone.

- Added comments in some of the examples showing what the console output would be.

- In some examples, changed logging to use JSON.stringify; otherwise, whole
object was logged

- Added discussion of invalid event to Validation section. Also added how
validate is automatically called on save and on set when validate option is true.
Added validate flag setting in validation example.

- Reworded note about the attributes object passed to validate.

- In 'el' discussion, noted ability to set el when creating view. Also added discussion
on $el and $().

- Added HTML for example view to the render discussion. Changed checkbox element in
template to conditionally set checked attribute as is done in the Todo Practical.
Made same change in chapter 2.

- Removed use of localStorage in Collection examples. Removed create() from initial
Collection examples so examples work without having a backing store (and without
introducing the concept at this point). Create() is introduced in the new RESTful
Persistence section noted below.

- Moved the Backbone.sync portion of the discussion under Fetching models from the
server to the Backbone.sync discussion later in the chapter.

- Expanded Fetching models from the server section into a new RESTful Persistence
section which also includes Saving models to the server and Deleting models from
the server. I think Backbone's persistence support and its ease of integration
with RESTful servers (I'm using it with Java/Spring MVC) is a key differentiator
between Backbone and other MV* frameworks. Please check for accuracy!

- Expanded the Chainable API discussion. I've used chained APIs in Java, but had
a hard time understanding what was going on in this example until I looked at
the Underscore documentation and code. Please check my new explanation for
accuracy!

- General wordsmithing

Recommendations:

- Move Conflict Management to another section (e.g., common problems or appendix)
- Move Inheritance and Mixins to another section
- Keep Dependencies initial section (perhaps state elsewhere), move subsections
(DOM Manipulation, Utilities, RESTFul Persistence, Routing) to appendix or other
section focused on Backbone internals
- Consider moving Namespacing discussion to later in the book (e.g., common problems)

Other comments:

- Object literal example is unclear; it contains two 'var myApplication' declarations
and most of its content in a comment. As a result, what is being recommended is unclear.

- REST sections will need to be updated to discuss HTTP PATCH support.