Open Biodiscus opened 9 years ago
I'm not sure I understand, do you have a problem with the player being a singleton?
Your logging example doesn't work- you wanted a singleton camera, and we can't just disable the camera and expect execution to stay the same.
There is only one local player, just as there is only one camera.
I would be happy to rewrite the camera class so it won't be a singleton. I still think the example is good, even when my old ideas say the opposite.
I'm not a fan of singletons, generally, but they work well here.
Singletons don't have to always be non-important (like logging), any situation where you only need exactly one of something globally is a fine place for a singleton.
Removing the singletons will require a ton of dependency injection all over the place.
Apart from general dislike of singletons (which I share, singletons make me sad) what issues do you see with our two singletons? What do they actually hurt?
From Wikipedia- This is useful when exactly one object is needed to coordinate actions across the system.
I am not to keen with the way it is from multiplayer perspective. I need a computer to write more about it. On 26 Jul 2014 17:36, "Jeremy Barnes" notifications@github.com wrote:
I'm not a fan of singletons, generally, but they work well here.
Singletons don't have to always be non-important (like logging), any situation where you only need exactly one of something globally is a fine place for a singleton.
Removing the singletons will require a ton of dependency injection all over the place.
Apart from general dislike of singletons (which I share, singletons make me sad) what issues do you see with our two singletons? What do they actually hurt?
From Wikipedia- This is useful when exactly one object is needed to coordinate actions across the system.
— Reply to this email directly or view it on GitHub https://github.com/TeamSweepy/Greywater/issues/28#issuecomment-50237402.
Rad, I'm happy to change it if its actually a problem. When you get back we'll talk about it.
Ziga and I discussed this, we'll still need a singleton, but it will be a player controller that is still a singleton that's only clientside, it will have a specific playermp registered to it and it will send commands to that object.
Somebody should really fix this!
http://stackoverflow.com/questions/228164/on-design-patterns-when-to-use-the-singleton
Quoting the top answer: Logging is a specific example an "acceptable" Singleton because it doesn't affect the execution of your code. Disable logging, code execution remains the same. Enable it, same same