In the course of developing my game, I have felt the need to start over multiple times and in every case it has been because I was unable to handle the complexity of the code base. As the code size and number of classes grows beyond a certain point, it all starts to look like a like a ball of mud. I don’t know how and where to make changes and I get a sort of numbness to the whole thing. I have been trying to improve the situation by:
1. using pre-existing libraries more
The less code you write, the less there is to manage.
2. Limiting dependancies.
3. Improving my documentation.
4. Separating out “framework” code from game specific code.
I have a separate Eclipse project for code that isn’t necessarily specific to this game. For instance, I have a Bag/Multiset implementation defined there as well as an Event/Messaging system.
While this has all helped, with my current iteration of the project, I have started getting that same sinking feeling and I want to stop it before it gets out of control. Some things I haven’t really tried that may help:
1. Organize my packages by something other than “type of thing”.
I put all of my entities in an
net.actual.entities package. I’ll put events in a
net.actual.events package. While this helps in one sense, in others it doesn’t. For instance, certain types of entities and events tend to be used together. Maybe I should organize packages by application layer?
2. Try to split more of the code out into separate projects.
Mentally it may help to look at fewer classes at a time, but I wonder how many independent pieces there really are.
3. Try to use a more data driven approach.
May lower the total class count and allow for the game to be defined using configuration files that could be simpler than the equivalent code.
4. Diagramming the system at a higher level (UML?)
Any thoughts? How do you architect and/or organize your code and keep it understandable as a whole?