[Kstars-devel] Making all sky components static

James Bowlin bowlin at mindspring.com
Mon Jun 16 22:21:59 CEST 2008


On Mon June 16 2008, Akarsh Simha wrote:
> Shouldn't we be making all sky components singleton classes? This
> will make some things easier, like accessing StarComponent from
> SkyMap or StarBlockList.
>
> Currently, I've made StarComponent::m_StarBlockList, and
> StarComponent::m_StarBlockFactory static members, so that
> StarBlockFactory and StarBlockList can access them easily, instead of
> passing around pointers to the StarComponent.

There are some SkyComponents that have more than one instance so trying 
to make those singletons will cause breakage.  It could be that many of
our StarComponents could be singletons but I would recommend a slightly 
conservative approach and suggest we only create singletons on an 
as-needed basis.

If you want to make StarComponent or any of your own classes singletons 
then I say go for it.  I would avoid making other classes singletons now
because I don't think it gains us much but it could cause a subtle bug
to be introduced that won't get detected for a long time.  Also, I think 
it would be better to make such over-all improvements in the trunk 
rather than in to GSoC branch.

Does this sound reasonable?


BTW: I don't think "singleton" is synonymous with "static" even though
they both imply "only one of".


-- 
Peace, James


More information about the Kstars-devel mailing list