[Kstars-devel] Making all sky components static

Akarsh Simha akarshsimha at gmail.com
Sat Jun 21 00:16:33 CEST 2008


> 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.

Ok. I didn't know that.

> 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?

Yes. I wanted to make StarComponent singleton. I don't know whether it
would make sense. We can avoid doing this with some pointer-passing,
but I don't think that will be clean. I like the idea of doing a
StarComponent::Instance()->m_StarBlockFactory rather than
StarComponent::m_StarBlockFactory that I presently do. The present
code will cause serious problems if there were two StarComponents
using this data structure - I doubt there will ever be such a
situation, but I'm looking at it from the code quality
perspective. Should I make StarComponent a singleton?

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

Yes. I didn't know that.

Regards
Akarsh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.kde.org/pipermail/kstars-devel/attachments/20080621/de1fbe69/attachment.pgp 


More information about the Kstars-devel mailing list