Quote:Original post by skittleo
Quote:Original post by jpetrie
The XNA stuff holds state, which starts to push them away from procedural free functions and more towards singletons. It gets murky... I don't particularly enjoy the design either, and I don't think it its a good, scalable one.
But don't you think for XNA's purpose (being easy to use, easy to learn, quick prototyping) static classes with state (... singletons?) work fine? A beginner learning to program in C# and create games can easily remember Mouse.X but they might not as easily remember or understand InputDevices.Mice[0].X. I'm just trying to make the point that sometimes singletons are OK.
Culture momentum.
Singletons have been shown and proven in many cases to be a bad practice. But this happened reasonably recently.
If you have a choice, use the "proper" design. But if you're stuck between legacy concepts, background compatibility, platform specific static nature of architecture, in addition to considering programming nothing but a 9-5 job, then you'll use singletons.
Just because it's still present doesn't invalidate its flaws. Look at the stuff still taught at universities. How much of it could be considered heresy these days (if you don't know what I'm talking about consider yourself lucky).
In other engineering branches culture changes when people die. It takes 100+ in a single accident, or more than insurance is willing to cover on yearly basis. Software doesn't kill anyone. So things change slowly (yet still blazingly fast compared to other engineering techniques).
This isn't about: "Look ma, Johnny's doing it, so I can too"
When asking when or how to use a certain design practice, look at design practices at your disposal, then evaluate them for their own merits and flaws. Copying concepts because someone else used them is hugely flawed.
This is the wikipedia syndrome. "I read it on wikipedia, so I'm an expert on topic". Singletons have their perfectly valid use, just like anything else. But if you look at examples and tutorials from past 10 years, almost all of them use static constructs.
Why?
These documents aren't reviewed or revised. Implications of the design aren't documented. And those who learn from them learn wrong concepts.
It was said long ago that BASIC ruined whole generations of programmers. Was BASIC bad? No. It was so easy people got into programming - but never realized that the concepts they took for granted were flawed, unscalable and useless in real world.
Singletons are today's BASIC.
Can VB be useful? Today, with today's .Net versions, with all the support APIs and VB for Applications, yes. But always remember what VB is. Coming into any serious software development with "VB experience" won't give you much crediblity.
About XNA: yes, it's attractive, it will allow people to make games.
But some of them will know nothing but. And then they'll have a rough encounter trying to get into either big-shot game design, or other software development positions. Those that do not understand the background, will be in for a very rough ride - not because they couldn't find a job - but because they'll be the COBOL programmers of yesteryear.
Knowing one framework, no matter how well, but without understanding the concepts behind it (even if flawed), is a sure way to obsoletion.