[In this reprinted #altdevblogaday-opinion piece, Fishing Cactus developer Fabrice Lete discusses how to go about using code from a previous game efficiently.]
Project number #n is done, it’s time to work on project number #(n+1). As you will keep the same technology but make a different game, you are now facing two options:
- 1. Copy the whole project #1 and start ripping out the parts you don’t need anymore.
- 2. Start everything from scratch.
- Aggressively delete all code that serves no purpose anymore as you go, code that is not called is a liability. And don’t comment it out, if you ever need it back, it will still be there in source control. Make it so that you can actually remove stuff without breaking the whole thing. And removing is not about having code that is not called, it really is getting rid of it (YAGNI).
- Avoid dependencies on the computer itself, use the project files instead. Use relative paths, use build command macros (read Paul Laska’s wonderful article here: User Defined Build Command Macros in MSVS 2010), standardize your naming, eventually use symbolic links (but be careful, they can get confusing).
- If you can store cross-project configuration outside the project itself, do it. Properties sheets in MSVC are great, use them and regularly push everything not project-specific in there. They also make it convenient to share settings amongst build configurations and give you a bird’s eye view.
- Reduce the amount of libraries you use. Sure, you should avoid reinventing the wheel, but when a reasonable amount of ad-hoc code can replace a large dependency, it might be worth considering. Also, unity builds work just fine for quickly including small libraries.
- Avoid excessive flexibility in configuration, group settings together. If something depends on something else make a naming convention so you can deduce one from the other. Don’t put all your symbol definitions in the project configuration, put them in headers where possible.
- Don’t make too many build targets, they will get broken at some point. The less you have, the less you have to fix. Only keep the ones you really need on a daily basis, and ensure that your build server covers them all.
- Be very careful with stuff that happens before main, automatic initialization seems convenient but will you still remember what triggers when and where a few years from now?
- When doing something in a way you suspect to be sub-optimal, make sure you leave a comment. And make it meaningful, it might be obvious at the time you write it but in a few months your “// lol hack” won’t help.