I
Ian Collins
That (destructing the object, and renewing it) is the case.James said:[...]James said:James Kanze wrote:I guess we bent the rules for our singleton objects to enable
then to be created and destroyed in tests. The single
instance is enforced through a base class template with a
static member pointer.
The problem with this is that you're no longer testing the code
you actually use.No, the code is the code we actually use.
But the context it's tested in isn't. Especially if you're
"resetting" a singleton. (I suppose that if you're actually
destructing the object, and renew'ing it, the difference is
minor. But I can still imagine cases where it might make a
difference.)
That's one reason why we construct everything from main(), restrictingExcept, of course, that it's running in a different environment.
That's partially unavoidable, of course, but in code that I
expect to be run before main(), I do ensure that it's tested
running before main().
static objects to pointers. When running tests on a different platform
form the eventual target, it pays to minimise the potential differences.
Initialisation order is one potentially significant difference.