Jump to content

  • Log In with Google      Sign In   
  • Create Account

Good habits for game development


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
35 replies to this topic

#21 wodinoneeye   Members   -  Reputation: 876

Like
2Likes
Like

Posted 21 January 2013 - 08:53 AM

Something from writing/fixing others code :

 

If there is some parameter flags that cause variations of behavior of a subroutine - clearly comment this  at the parameter definition and down in the code where trhe different modes take action.  (Im not talking about simple subroutines but ones hundreds and thousands of lines long that it may not be productive to have a variant copy customized for each 'mode'.)

 

Especially if the scope of the differences cause odd side-effects or have important limitations.

 

Document those (if not anything else) becase of the amount of the time/effort it takes to trace thru the code again  to figure out what it does and once you find it (as when fixing other peoples poorly documemnted/commented code)  it can save the effort or repeating the detailed logic tracing.

 

Anything with weird/atypical/convoluted behavior should get priority for comments if there is little time for any done systematically (its just a fact in the real world that you dont always have the resources to do a full commenting/documentation).

 

----

 

 

And when I make many such comments I make them very plainly stand out so that its hard to miss  (indicating that the codes behavior is something to be wary of)


--------------------------------------------Ratings are Opinion, not Fact

Sponsor:

#22 l0k0   Members   -  Reputation: 278

Like
2Likes
Like

Posted 22 January 2013 - 01:36 AM

Some general things, most of them independent of coding style:

 

- Have realistic and well defined goals that are clearly communicated to members on your team

- Scope it down: your game idea is probably too damn big.  Polish takes time, things get cut, features don't exist in a bubble (unless the project fails that is).

- Iteration time is everything: Fail early and fail often, prototype mechanics, and be prepared to cut something you invested a considerable amount of time in

- Knowledge is power: profile your code, run tools that check for leaks, crank up compiler warnings, and use static analysis tools if possible

- Interfaces are king: A well designed one is the root of a clear, maintainable, and productive workflow for others.  A poor one will cut into iteration time.

- Understand that hard problems will inevitably contain immensely complex code: elegant systems rarely survive contact with real users

- Embrace time estimates and embrace making time estimates that might be completely wrong.  Do this over and over and over again.

- "Self Documenting Code" is probably only documented to you

- It's (usually) not done until it's data driven

 

 

 


Edited by l0k0, 22 January 2013 - 01:38 AM.

<shameless blog plug>
A Floating Point
</shameless blog plug>

#23 SeraphLance   Members   -  Reputation: 1454

Like
1Likes
Like

Posted 23 January 2013 - 11:32 AM

If there is some parameter flags that cause variations of behavior of a subroutine - clearly comment this at the parameter definition and down in the code where trhe different modes take action. (Im not talking about simple subroutines but ones hundreds and thousands of lines long that it may not be productive to have a cariant copy customized for each 'mode'.)

 

I'm going to agree here, on the caveat that youl should avoid writing this kind of code as often as possible in the first place.  Sometimes it's unavoidable, but it's a code smell that should be minimized.  A function should ideally do one thing.  It's not really one of those lofty architecture astronaut ideals 99% of the time either.



#24 Plethora   Members   -  Reputation: 679

Like
1Likes
Like

Posted 28 January 2013 - 09:08 PM

Incredibly helpful thread! 

 

Here's my tip... define your goals ahead of time, both for yourself and for the project.  If you're doing it to learn then take every chance to learn.  Try out new approaches to various coding problems even if you're already comfortable of some other way of doing something.  Having more tools at your disposal for the future is what learning is all about.

 

On the other hand, if your primary goal is to create an awesome game and to hell with everything beyond it, then do the opposite of the above.  If you know a way to solve a problem, don't worry about whether or not its the best way or even necessarily a good way, provided it works and it does the job you wish it to do. 

 

In reality, most projects are going to be somewhere between those two extremes.  Learn how to balance the benefits of taking time out of your project to learn something new versus just powering through with what you have understanding that there might be better ways of doing things out there but knowingly declining them for now.


I'm working on a game!  It's called "Spellbook Tactics".  I'd love it if you checked it out, offered some feedback, etc.  I am very excited about my progress thus far and confident about future progress as well!

 

http://infinityelephant.wordpress.com


#25 HAM   Members   -  Reputation: 176

Like
2Likes
Like

Posted 29 January 2013 - 07:02 AM

For games, especially if you are designing, you are much less an engineer and much more a sculptor, constantly pushing and pulling things around, removing unneeded bits and adding extra bits.  Plan for things to change, 

 

  1. Get a playable version as fast as possible. Even if it all gets thrown away.
    • Prototyping is a design step, a pre-production step.
    • Its going to help in planning and identifying what really needs to be implemented.
  2. Design up front just enough to get a good idea of what you really need.
  3. Implement the minimal amount.
  4. Schedule the minimal amount.
  5. Art and sound and nice assets can wait.  Make things work first.

 

And the last thing is my personal law for programming.  It might sound stupid but it helps in about a million ways.

  • Never write a function longer than 50 lines (including white space and comments).  Decompose. make it fit on a single page.  

Edited by HAM, 29 January 2013 - 11:08 PM.


#26 NightCreature83   Crossbones+   -  Reputation: 3032

Like
0Likes
Like

Posted 29 January 2013 - 09:33 AM

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 :)
 


Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, Mad Max

#27 StrangeTurtle   Members   -  Reputation: 133

Like
1Likes
Like

Posted 29 January 2013 - 05:08 PM

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.


"Oh, God, I'm nervous. Two of my three hearts are having attacks." -Zoidberg
Site: http://www.strangeturtle.com


#28 jwezorek   Crossbones+   -  Reputation: 1974

Like
0Likes
Like

Posted 03 February 2013 - 08:44 AM

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, 03 February 2013 - 08:46 AM.


#29 SiCrane   Moderators   -  Reputation: 9668

Like
1Likes
Like

Posted 03 February 2013 - 09:10 AM

The git wiki has a page listing free git hosting sites. Unfuddle does appear on the list.

#30 Serapth   Crossbones+   -  Reputation: 5751

Like
0Likes
Like

Posted 03 February 2013 - 09:35 AM

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...  



#31 SiCrane   Moderators   -  Reputation: 9668

Like
0Likes
Like

Posted 03 February 2013 - 09:46 AM

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.

#32 Serapth   Crossbones+   -  Reputation: 5751

Like
0Likes
Like

Posted 03 February 2013 - 09:53 AM

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.



#33 SiCrane   Moderators   -  Reputation: 9668

Like
1Likes
Like

Posted 03 February 2013 - 10:06 AM

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.

#34 Serapth   Crossbones+   -  Reputation: 5751

Like
0Likes
Like

Posted 03 February 2013 - 10:31 AM

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.



#35 SiCrane   Moderators   -  Reputation: 9668

Like
0Likes
Like

Posted 03 February 2013 - 10:53 AM

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.

#36 Serapth   Crossbones+   -  Reputation: 5751

Like
0Likes
Like

Posted 03 February 2013 - 11:10 AM

 

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, 03 February 2013 - 11:11 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS