On 2/8/12 1:50 AM, "David Arno" <da...@davidarno.org> wrote:

>> From: Alex Harui [mailto:aha...@adobe.com]
>> Sent: 08 February 2012 03:10
>> 
>> ... And then there are some old singletons like EffectManager that still
> use
>> static methods, which should be using Singleton instead.
>> 
>> And then there is the whole debate about Singletons in general...
> 
> Let's have that debate. Replacing static methods with singletons will not
> improve the testability of the code. If those static methods are
> deterministic and have no side effects, then they are fine as static methods
> (and maybe could be turned into global functions as a minor [though
> controversial] improvement.) Otherwise, they need to go.
I don't fully agree.  I don't see how static methods on a class are
substitutable at runtime without resorting to evil tricks.  Static methods
require hacks for event dispatching and can't implement interfaces.  But for
sure, a bad instance method implementation can also make substitution
difficult.
> 
> Global state, whether via singletons, service locator patterns or static
> methods, always make testing difficult. If we are serious about making the
> Flex framework unit-testable, then we need to get rid of all of them and
> replace them with dependency injection throughout the framework. Anything
> less will - from a testing point of view - just be fiddling whilst Rome
My simple mind just can't understand why we need a sophisticated multi-step
plan or full dependency injection.  Why can't a simpler substitution pattern
do the job?  

-- 
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui

Reply via email to