Development Process – How to Avoid Typo Errors in Code

code-reviewsdevelopment-processerrors

For the first time I have been coding for an open-source software where all my work gets reviewed before being commited. I understand reviewing work isn't an easy task, so I don't like to waste reviewers' time and effort. But many times I make silly typo errors and errors of other kind while making a change in the code.

For example, the last time when I refactored some old code I moved code from one class to another, but forgot to check that $this only worked in the old class and needed to be changed now.

I do run unit tests, but sometime they miss these errors (we have incomplete test coverage right now). And I agree that many times I am in a hurry to submit the change only to get the work done faster.

But, besides wasting reviewers' time, this actually slows down the development process and reduces my credibility (small errors may even hide praise for good work).

What's the best way to avoid such a scenario or, in other words, how can I review my own code before someone else does?

Edit: I use Notepad++ for PHP, please don't ask me to change the IDE right-away; however, suggestions are welcome if they are persuasive 😉

Best Answer

You have already answered your question by yourself.

There are several things that one should always remember when developing (no matter what language, IDE, project is on your desk):
- When developing, try to think only about the project you're working on. Everything else should be forgotten for a while, including the praise you'll get if you do your work well. Such thoughts will only distract you, and you'll make more mistakes as result.
- Don't hurry, if it isn't vital for the project. Take your time, try to test everything properly. As you mentioned, the fast-written but full-of-bugs code is not something to be proud of. I'm sure if you don't hurry so much you'll be able to detect many bugs by yourself.

And, as mentioned in other answers, run unit tests. And one more. There will ALWAYS be bugs. No one is perfect. But these two rules will help you reduce their quantity.

Related Topic