I have been a professional C programmer for almost 10 years now. I am planning on posting about various things I learned about programming. Everything from language specific tricks to general software development strategies.
Here are some of my general programming guidelines that I intend on discussing in more depth at a later time.
- Beware of speculative programming, aka programming features you think you'll need in the future. Instead write your code so that it is simple and flexible so that new features can be added easily. This includes worrying about performance before you can measure the performance of the whole system.
- Always keep your code running. Have a testing framework that you can run to verify the correctness of your changes as you make them. Make small changes and verify often. This is very similar to the ideas of Test Driven Development.
- Programming Languages are tools. Use the appropriate tool for a job. Using the wrong language for the job is like try to drive a nail with a screwdriver. Perl is great for file and string manipulation. C is great when speed actually counts.
- Good programmers learn new languages easily. Experts in a particular language may not be good programmers. It is usually easier to teach a good programmer a new language than make a language expert a good programmer.
- For the love of God, stop making your code uglier to reduce the number of lines in a file. Compilers ignore whitespace, but it can be very helpful for other programmers.