Showing posts with label Mixins. Show all posts
Showing posts with label Mixins. Show all posts

Friday, March 22, 2013

Mixins in Ext JS 4 - On why mixins are useful

Mixins are really useful when a class needs to inherit multiple traits but can’t do so easily using a traditional single inheritance mechanism. For example, Ext.Windows is a draggable component, as are Sliders, Grid headers, and many other UI elements. Because this behavior crops up in many different places it’s not feasible to work the draggable behavior into a single superclass because not all of those UI elements actually share a common superclass. Creating a Draggable mixin solves this problem – now anything can be made draggable with a couple of lines of code.
http://edspencer.net/2011/01/classes-in-ext-js-4-under-the-hood.html

Tuesday, May 29, 2012

Mixins vs. OO

[M]ixins are a type of inheritance ... Inheritance is fundamentally at odds with encapsulation, the addition of capabilities to objects with a single line quickly muddle the responsibilities of classes, and mixins themselves aren’t even the best option for code reuse across classes.
 http://justinleitgeb.com/2012/05/moving-beyond-mixins/