Wednesday, March 27, 2013

prototype members should be methods

You want the members of prototype objects to be methods. Adding objects which itself contain methods doesn't sound like a good pattern. – Šime Vidas http://stackoverflow.com/questions/8693279/javascript-accessing-parent-properties-from-inside-nested-function

Tuesday, March 26, 2013

JSON.stringifying a Circular Reference

You can use the replacer function approach to blacklist member names (in contrast to how the replacer argument as an array whitelists member names). I’ve found this approach to be useful when I need quick and targeted logging of certain values from a DOM element, but I want to prevent a serialization exception due to attempting to serialize a circular reference (which would occur if I drank some antifreeze and attempted to do something ridiculous like JSON.stringify(document.body)). 
http://freshbrewedcode.com/jimcowart/2013/01/29/what-you-might-not-know-about-json-stringify/

Friday, March 22, 2013

Refactoring is an Art

Which Choice should we work on first? Should we move logic to A first and then B, or B first and then A? How much do we work on one Choice before moving to the next? What about other refactoring opportunities we see as we go along? These are the kinds of succession questions that make refactoring an art.
Kent Beck

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