Re: Can use of singletons denote poor project design?
- From: "Daniel Parker" <danielaparker@xxxxxxxxx>
- Date: 24 Feb 2006 13:25:29 -0800
Phlip wrote:
Daniel Parker wrote:Changes the format to something other than what is required for the
I don't really see how there are any special issues for writing unit
tests for singletons. For example, in Java, DateFormat.getInstance()
returns a default date format, which is a singleton object, there is
one instance of a default date format. Are you suggesting that you
would have difficulty testing whether this object satisfied its
specified properties? Why?
Could you outline a test that changes the format, calls a method that relies
on formatted dates, and test its output is correct?
default format? Why would you want to do that?
Presumably the default format depends on the default locale, so to test
that you could set the default locale and then test that the properties
of the format returned by getInstance() were as required.
Could we then make the test just a tiiiiny bit simpler by taking out theDepends what you're testing. The proposed test was for the default
singleton and passing the date format directly?
date format. You seem to be testing something else.
To make the test case harder, suppose in System Q the CurrentTime is aHuh???
singleton (because, gee, time is a universal constant, so there's only one
of them). Now write a test that depends on a specific date to pass its
assertions.
Regards,
Daniel Parker
http://servingxml.sourceforge.net/
.
- Follow-Ups:
- 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?
- 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
|