My top programming tips:
- It is more effective to comment why as opposed to how or what. When you look at some special case condition 6 months later it is easy to tell what you did or how you did it, but you probably won't remember why you did it.
- It takes a lot longer to recode than it does rethink a problem so time spent thinking about a problem is far more productive than time spent coding a problem. However, planning for future design possibilities that you don't understand usually only results in a bloated design that doesn't fit the problem. The best approach is to think through a problem as much as you reasonably can, code that solution, and later refactor as needed.
- Never have the same code or data in more than a single place in source or in memory. Repeated code should go in a function while repeated data should be accessed through accessors.
- Refactor your code as soon as you fully understand a problem that you didn't properly account for. Putting off refactoring encourages further sloppy design and is more difficult to do when you no longer fully remember or understand the solution.
- Don't worry about speed optimizations during development. When it is time to optimize, don't try to guess what is slow and what is not. Profiling and optimziation are cause and effect.
- The more asserts you use, the more likely you will catch a bug earlier and the easier it will be to fix.
- The time saved by using a programming tool will almost always exceed the time spent writing the programming tool.
- The number of total errors tends to be proportional to the number of syntax errors caught by the compiler. Therefore, the number of errors reported the first time you compile new code is an indicator of how well written your code was and how long you will spend debugging. Take more care when writing new code and you'll spend a lot less time on it overall.
- Hungarian notation is documentation on a variable's type. Why write and maintain documentation for something your compiler will immediately tell you via context help? If you insist on using this, at least use it for its original purpose, which was to document INTENT, not type.
- The key to successful architecture design is to maintain generality among components. Doing so tends to create reusable modules of code which interact with each other though flexible and well defined interfaces.
- Script systems are a valuable tool because they make it easier for non-programmers to easily set up and modify game code and other data. However, they are a poor choice for programmers as programming in script is non-portable and programmers lose access to their most powerful tool: the compiler. Use the best tools for the job at hand.
Links to stuff I've done