recipeswithbackbone/recipeswithbackbone.github.com — Issue #23: change our inheritance style
Author: ngauthier
Created: 2011-11-30 15:46:23+00:00
State: open

We're using _.extend's ability to accept additional mixin classes for exension:

```javascript
Modules.X = {
foo: function() { }
}

Views.Y = Backbone.View.extend(_.extend({
bar: function() { }
}, Modules.X));
```

This is simple and is a great way to do mixins in a ruby-module-style. However, we're using this in a few recipes where "real inheritance" would be more appropriate than a mixin. With more work on the module we can create a real prototype chain:

```javascript
Views.X = Backbone.View.extend({{
foo: function() { }
});

// Then the view just extends the other view
Views.Y = Views.X.extend({
bar: function() { }
});
```

The difference here is mixin vs inheritance. I think for the most part we're using mixins right in our recipes, but there may be a few cases for inheritance.

This is taking advantage of a special behavior of Backbone's extend (which is different from _.extend) and is self-propagating:
http://documentcloud.github.com/backbone/#Model-extend