Hi

> This is way off-topic wrt the original post, but ah well.

Hardly. I'd say it was all very relevant. Especially to starting and 
stopping the COM runtime.

> I've always been of the 'globals-are-evil' school myself, however 
> recently I've started reconsidering. For example, what do you suggest 
as 
> a good way to handle an object like a Preferences object, something 
that 
> you need almost everywhere? It would of course be possible to pass 
> around pointers from function to function but you'll have to agree 
that 
> that is even more ugly than a global object. 

That's as maybe, but it is still the correct thing to do.

Just don't mention singletons!

> What's more is that it is 
> always possible that you'll have to add a preference later where you 
> didn't anticipate it, so you'd have to redo all functions that lead 
to 
> that point. 

I've not quite with you. If you make you preferences an object or a 
struct all you will need to do is add a new data member and recompile.

> IMHO this is a case where a global object is very useful. 

I think you're wrong.

> I've also tried using a static function in the Preferences class 
before, 
> but in the end that's just a global in disguise.

Indeed and it's far to much like a singleton for my liking.

> How do you suggest handling this without globals?

As you suggest above you should create your preferences object at the 
highest level and pass it around by reference or pointer.

Regards
Paul

Paul Grenyer
Email: [EMAIL PROTECTED]
Web: http://www.paulgrenyer.co.uk

Have you met Aeryn: http://www.paulgrenyer.co.uk/aeryn/?
Version 0.3.0 beta now available for download.




Reply via email to