incubator-flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Heidegger>
Subject Re: [RT] From Singletons to Unit-testable code
Date Wed, 08 Feb 2012 09:58:57 GMT
On 08/02/2012 18:50, David Arno wrote:
> 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. 
> 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. 

I could be wrong but I think the plan I wrote about was a step-by-step 
instruction to get rid of singletons using a intermediate service 
locator that can be dropped in the end.

To me the first step is to get from "unit tests are impossible" (the 
current state of the framework) to "they are do-able".  Then unit tests 
could actually be written. With unit tests available it would be safer 
to ease to a system without a global state.


View raw message