Posted by Mike on Jun 4th, 2010
On the SRP:
For those unfamiliar with the Single Responsibility Principle (SRP), it states that there should never be more than one reason for a class to change.
That is to say: do one thing, do it well.
Decorators (not to be confused with the decorator pattern) can add behaviors or side-effects to a method, and this can [...]
Posted by Mike on Jan 13th, 2009
We generally preach that you should not use real data in your unit tests. You should instead mock said data out in an effort to lesson potential side-effects, including degrading test performance and adversely affecting live data.
Sometimes, you’d like to test actual file handling in a unit test. If you do, you should [...]
Posted by Mike on Oct 2nd, 2008
Here’s a quick example of how to incorporate the Decorator Pattern into your javascript code using the Dojo framework. Rather than decorating an entire class, this example merely decorates a single function, extending the original function with some extra logic.
// Instantiate widget class
var w = new core.widget.MyWidget();
// Decorate the original "method1" function
var _old_method1 = [...]