Jump to content

View more

Image of the Day

#ld38 #screenshotsaturday Mimosa Fizz action gif #2 https://t.co/TUzdppvfUL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Need help organizing code... its a complete mess.

4: Adsense

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
2 replies to this topic

#1 alphster   Members   

122
Like
0Likes
Like

Posted 27 June 2011 - 11:04 PM

I was hoping someone might know a good book or resource for me to study up on that'll teach me how to better organize my game code. I've been working on Pacman and it feels like the code is all over the place. I've resorted to using Global variables everywhere and i'm not sure if i've created the most optimal classes.

Anyone know a good book? Generally, the examples in most of these XNA books are simple games and they put all the logic into the Game1.cs file. I'm looking for a better structure than that...

#2 Dawoodoz   Members   

459
Like
0Likes
Like

Posted 28 June 2011 - 04:17 AM

Learning pure functional programming is a good way to learn how to divide a giant routine with side effects into many small well defined functions that are thread safe and can be tested out of context.

"App". is an acronym and must always be followed by a dot.

https://en.oxforddictionaries.com/punctuation/punctuation-in-abbreviations


#3 rip-off   Moderators   

10897
Like
1Likes
Like

Posted 28 June 2011 - 05:10 AM

Forcing yourself to remove global variables will be part of it. Applying the Single Responsibility Principle will help too. Reducing dependencies is another powerful tool. Inverting the dependencies or introducing some kind of pure abstract "mapping" layer (often in the form of callbacks, or delegates).

Personally, this is something I learned by writing bigger and bigger programs, to the point where I couldn't maintain my older style so I was forced to abandon globals and really start separating things out into smaller units. Even then, it wasn't until I was working where I learned the value of unit testing, and totally minimising the dependencies so everything can be tested in isolation.

That is my excuse for not having many good resources to point you to. However, here are some excellent articles on programming design principles:





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.