I feel guilty for creating a static class in my otherwise OOP game engine!
Am I a sinner? Am I in need of purifying redemption? Am I the spawn of the devil?
I feel guilty for creating a static class in my otherwise OOP game engine!
Am I a sinner? Am I in need of purifying redemption? Am I the spawn of the devil?
We have a name for your pain⌠Misssster Singleton
[quote]We have a name for your pain⌠Misssster Singleton
[/quote]
Aye, but is static really that bad of a thing?
[quote]Aye, but is static really that bad of a thing?
[/quote]
Depends on what youâre doing. A lot of utlity classes donât really need instances, so static methods are used. Singleton patterns are another example of where statics are useful.
How about you tell us what itâs for, and then we can give a yay or nay?
Static classes are nice for math operations that donât come with Javaâs Math class.
Thatâs what I use it for, to calculate physics.
If thatâs what how youâre using it for then you are correct.
Singletons are only needed if you require a single instance of a class for the entire lifetime of your program.
Iâm sure someone can give you some examples of this.
Iâll do my best, not sure how to explain it.
Itâs for a loading system that is used to queueâs âLoadableâ (interface) objects to be loaded, and then processes them.
Itâs basically so I can easily set up progress bars and the like by running through the queue and updating the screen as I go. I didnât really see a reason to have it a Singleton.
Hope that made some sense. :-\
i use static classes if i only need one instance of a certain class, which are usually controllers for things, like the controller for enemies is static, but the enemies them selves are not.