Re: Can use of singletons denote poor project design?
- From: Phlip <phlip2005@xxxxxxxxx>
- Date: Fri, 24 Feb 2006 22:58:51 GMT
Daniel Parker wrote:
This discussion of a Singleton and related abuses is using the wrong
example.
I think it's using the right example.
A global that production code never writes on is mostly harmless. So it's
not the right example of the kind of Singleton that will irritate test
cases. Plenty of globals and Singletons won't (like I said before).
I suggested a test case that uses the defacto-global behind time() as a
little bit harder. You must wrap time() in a class, extract an interface,
write a mock time that returns a hard-coded, predictable time, then pass
the interface into everything that uses the time.
There - a test case has forced a global to become local.
--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
.
- Follow-Ups:
- Re: Can use of singletons denote poor project design?
- From: Daniel Parker
- Re: Can use of singletons denote poor project design?
- References:
- Re: Can use of singletons denote poor project design?
- From: Daniel Parker
- Re: Can use of singletons denote poor project design?
- From: Phlip
- Re: Can use of singletons denote poor project design?
- From: Daniel Parker
- Re: Can use of singletons denote poor project design?
- From: Andrew McDonagh
- Re: Can use of singletons denote poor project design?
- From: Daniel Parker
- Re: Can use of singletons denote poor project design?
- Prev by Date: Re: Can use of singletons denote poor project design?
- Next by Date: Re: Can use of singletons denote poor project design?
- Previous by thread: Re: Can use of singletons denote poor project design?
- Next by thread: Re: Can use of singletons denote poor project design?
- Index(es):
Relevant Pages
|