I make a fair amount of small mistakes when I code (things such as getting an angle bracket to the wrong direction). It adds a fair amount of time to my coding because I have to debug several times and iron out the dinks. Have you got any advice on how to stop these mistakes creeping in?
|
closed as not constructive by MichaelT, BЈовић, ElYusubov, Jalayn, Walter May 10 at 13:51
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or specific expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, see the FAQ for guidance.
|
The best method I have found is to follow test-driven development, and just write or change a small amount of code before running the tests. Then if there is a failure, you only have to analyze the small amount of new code. This means that every interesting method needs a test. |
|||||||
|
|
Here are a fiew options to eliminate annoying and common coding mistakes:
|
|||||
|
|
Some editors and IDEs will auto-complete lots of small things for you, such as adding in braces, brackets, parentheses, as well as partial code structures for loops, etc... Yours might have that option and it might help to learn how to use it and take advantage of it. |
|||||||||
|
|
Pair Programming is great for catching small mistakes. The downside is that it requires a second developer. The upside is that you get great code quality. When my company did some experiments with pair programming, my partner and I would often get code that worked correctly the very first time it was run. |
|||
|
|
The Personal Software Process, from the same folks who created the CMMI, has a methodology that I find useful in ferreting out the kinds of coding mistakes that you are looking to eliminate. The PSP provides a checklist of common coding mistakes -- missing semicolons, unbalanced parentheses, and the like. The PSP mandates that you perform this check of your code before you even compile:
The key is to only look for one type of coding error at a time. Narrowing your focus leads to much more effective detection. The other key point is to customize the checklist over time to include the kinds of mistakes that you are most likely to make. |
|||
|
|