|
|
|
|
|
by ad133
3188 days ago
|
|
Game dev is different than back-end server dev, is different from front-end web or desktop dev. For example, in back-end Java dev, I never use singleton objects in the truest sense of the pattern; singletons cannot be mocked out to test units in isolation. Instead, instantiate it with a dependency injection container and let your framework (Guice, Spring) wire things together. In effect, your global state becomes contained within a single context. Nothing stopping you having two contexts in the same runtime environment though. I find static methods are okay if they are concise and have no state; in particular if I'd never want to test the caller without it making the call to the static method anyway. This is becoming more important with Java 8's lambdas and needing to write helper methods. On the other hand, the cost of doing this might not be worthwhile for a game dev? Do game devs write unit tests? I have no idea. |
|