Adi Levin's Blog for programmers

June 1, 2011

Incremental coding

Filed under: programming — Adi Levin @ 5:15 pm
Tags: ,

As I keep developing my programming skills, I am always looking for ways to make my work more efficient, and to write bug-free code. In particular, I use what I like to call incremental coding.

The idea is that when you modify a feature in your program or add a new feature, you should take small steps, and perform testing and code review, and commit to the source-control after each step. I always prefer this over writing a lot of code that doesn’t work, and then entering a long debugging phase.

When your development is done in small steps, code review becomes much more efficient. When there only few changes in each step, you can almost prove the correctness of the code by reviewing the differences from the previous version. If there are lots of differences in each step, code review is still important, as it can detect certain issues, but it can no longer serve as a proof of correctness. 

The other advantage of incremental coding is that unit testing becomes more efficient, because of the same reason. When the changes are small, it is easier to design unit-tests or integration tests that prove the correctness of the code.

And what I also like about this approach is that your program works all of the time. You don’t enter a long period of time in which the program doesn’t work. You get to see the effect of every little change separately, and this helps find bugs.

I do as much incremental coding as possible, and from my experience, it keeps the number of bugs low, and shortens the development cycle significantly.


Blog at