Jump to content

  • Log In with Google      Sign In   
  • Create Account


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


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

Sponsor:

#2 Dawoodoz   Members   -  Reputation: 284

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.

My open source DirectX 10/11 graphics engine. https://sites.google.com/site/dawoodoz

"My design pattern is the simplest to understand. Everyone else is just too stupid to understand it."


#3 rip-off   Moderators   -  Reputation: 6916

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.



PARTNERS