• Advertisement
Sign in to follow this  

Good habits for game development

This topic is 1812 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Even when you are the single developer of a project write code as if it is intended for other people to use. You will be the other people when you look back at your code in 6 months time.

 

 

Side note:

For C++, I'd recommend reading C++ Coding Standards by Sutter and Alexandrescu. The table of contents
by itself is helpful, but the full book contains discussion like
reasoning and exceptions to the general rules. The only problem is that
it predates C++11.

 

I like this quote on the amazon link: "Short is better than long: Huge coding standards tend to be
ignored; short ones get read and used. Long Items tend to be skimmed;
short ones get read and used."

And then you release a 240 page counting book as a coding standards that's a brilliant way of contradicting yourself :)
 

Share this post


Link to post
Share on other sites
Advertisement

And in general, what I should consider for become a better game developer and make better games?

 

Finish what you start ... when you start a game, finish it.

 

This leads to a natural corollary, Don't start things that are too big for you to finish.

To add to the "too big for you to finish, " I hope your big project reuses code structure from previous projects to increase familiarity and speed to finish.

Share this post


Link to post
Share on other sites

the free online repository site I'm using has a built-in issue tracker

 

Which free online repository site are you using?

Didn't want to sound like I was advertising, nor stir up a Git vs. Hg firestorm, so I didn't name names, but I suppose there's no harm in saying Bitbucket. Github probably has similar features, but the deciding factor for me was Bitbucket's unlimited free account for those with a .edu email address. As a broke grad student, I couldn't turn that down.

Just to add to this for the benefit of other people reading this thread, I use unfuddle,com for source control on my personal projects. It allows totally free svn repositories to anyone but with the free account you can't have multiple users on projects. I don't know if they provide source control using software besides subversion.

Edited by jwezorek

Share this post


Link to post
Share on other sites

Stick to a singleton if you need something like a global.

 

Sorry, but if you've been using singleton's "instead of" globals then you have still been using globals during the past 8 years.  A singleton isn't better than a global just because it's wrapped up in a fancy class, and using a singleton because "you need something like a global" is a terrible reason to use the pattern.  You should use a singleton if you need a singleton; that is:

  • If there must only ever be one instance created.  Note that this is different from only wanting or needing one instance -- if you only want or only need one instance then don't bother with additional code to enforce it and instead only create one -- the singleton is appropriate when it would be an error for there to be more than one instance.
  • If you need global access.

 

Unless you need both of those requirements the singleton is not the right pattern for your situation, and it's exceedingly rare to genuinely require that there must only be a single instance.  

 

There is one other bullet:

 - deferred allocation.

 

I also dont think single instance classes are all that rare.  Of course you could design around the requirement.

 

 

It is also worth pointing out a few pro's about singletons.  First off, the most nasty evil horrible stuff about singletons is mostly only applicable to C++.  Singletons in Java or C# are nowhere near the landmine they are in C++.

 

Second, they are easy to grok.  That's why you see them in use in a number of very successful game libraries.  They may not make for the purest design, but they make for one that is generally easily comprehended.  This is why you see singletons used in Moai, Cocos2D, Ogre3D, PlayStation Mobile, etc... etc... etc...  

Share this post


Link to post
Share on other sites
There's nothing about deferred allocation that requires a single instance or global access. You can have deferred allocation with a class that you can have multiple instances of. You can have deferred allocation with local or member variables.

Share this post


Link to post
Share on other sites

There's nothing about deferred allocation that requires a single instance or global access. You can have deferred allocation with a class that you can have multiple instances of. You can have deferred allocation with local or member variables.

 

Yes, but it is a trait of the singleton.  I am not saying there aren't other ways to accomplish the same thing, but it is one thing a singleton gives you.

Share this post


Link to post
Share on other sites

Yes, but it is a trait of the singleton.

No, it's not. Singleton is two things: single instance and global access. That's the definition. If you have those two things it's a singleton. If you don't then it's not. Some common implementations have deferred allocation, but you don't need a singleton to do it and a singleton doesn't require it. If you want deferred allocation there's no reason to go and restrict your deferred allocated class to a single instance and force it to have global access, which is exactly what you are saying to do if you're saying reach for a singleton when you need deferred allocation. Deferred allocation is orthogonal to both number of instances a class can have and scope of access. That's saying every time you need to use new (a deferred creation mechanism) you should have a singleton.

Share this post


Link to post
Share on other sites

That's saying every time you need to use new (a deferred creation mechanism) you should have a singleton.

 

No, its not.  Allocation and access are coupled with a singleton.  If new was smart enough to not new an existing object, I would agree with you.

 

I am also not saying that if you want deferred allocation, use a singleton.  I am saying a singleton provides that trait, nothing more.  So, if you have a global object, that requires a single instance and you want to defer it's allocation until first access, a singleton provides this.  I am not saying other data structures don't, nor that there aren't other ways to accomplish this.

Share this post


Link to post
Share on other sites

Allocation and access are coupled with a singleton.

Not part of the singleton definition. Allocation can happen before a singleton is first accessed and it would still be a singleton. And you can couple allocation and access for an object without bringing in either global access or single instances of the class.

I am also not saying that if you want deferred allocation, use a singleton.

Yes, you did! You added deferred allocation to jbadams list of times when you need a singleton.

I am saying a singleton provides that trait, nothing more.

No, it doesn't! A singleton is defined by two traits: single instance of a class and global access. Common implementation often have deferred allocation, but it's not a requirement. Ex: a Meyer's singleton can be constructed before first use.

So, if you have a global object, that requires a single instance and you want to defer it's allocation until first access, a singleton provides this.

Which is saying that if you want a singleton with deferred allocation, then you want any old singleton! You're confusing a common implementation detail of a pattern for part of that pattern.

Share this post


Link to post
Share on other sites

 

I am also not saying that if you want deferred allocation, use a singleton.

Yes, you did! You added deferred allocation to jbadams list of times when you need a singleton.

Well that would be the crux of the disagreement between us.  I read jbadams post as times you could use a singleton, not when you need one.  In re-reading his post, I will admit outright, this was a mistake on my behalf.

Edited by Serapth

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement