Many years ago, back in Uni, I saw 2 guys in a computer lab writing a whole programming assignment without running it even once. The program was of relatively decent size written in C and consequently there were hundreds of compilation errors. That’s so silly, I thought…
After graduation I used to be a C++ programmer. The syntax sometimes was quite tricky and you would often compile after every new line of code. Sometimes, you would dare to write a whole function, just to find 10 compilation errors.
Since then the way I code has changed with help of modern IDE, Visual Studio as well as ReSharper – a productivity plugin. I never get to use just a simple text editor to write a program anymore. Real time static code analysis allows writing code while checking for compilation errors in the current file. With abundance of automatic refactorings a developer can efficiently manipulate a large amount of code. However, there might be a compilation error in another part of the solution, you still need to run unit tests, debug etc.
Now, for quite some time I’ve been using a new tool called NCrunch - a real time code coverage tool. The idea is simple: it builds Visual Studio solution and runs all available unit and integration tests automatically in the background while you are still typing. There is no need even to save a file. Initially, I thought to give it a go, as it was an innovative way to quickly see the code coverage. However, it turned out to be much more than that…
As my code has a fair amount of automated unit and integration test coverage, the entire system becomes “alive”. Combination of Visual Studio, ReSharper and NCrunch creates quite an extraordinary experience. Not only do I not build my solution too often these days, I only occasionally need to debug my code.
While typing you are being notified of any compilation error, any broken logic, any not registered component in DI container, any db error, etc. (assuming there is automated test to cover those scenarios)
The new experience reminds me of those guys from the uni lab, who never got to run their program before finishing the entire assignment. Not only technologies and development practices are evolving, but the entire coding experience is evolving too. In the past I have followed the pattern: code – build – code – build – debug – code…. Now my development pattern is: code – code – code – code – deploy. (I still need to debug occasionally)
There are additional, interesting projects promising to further revolutionize the ways we interact with computers through programming languages. One such idea is real time state output of a method while it is being written. Here is amazing video by Bret Victor – Inventing on Principle: http://vimeo.com/36579366. There was one attempt to achieve the same in c# code. http://ermau.com/making-instant-csharp-viable-visualization/ https://github.com/ermau/Instant It looks very promising for algorithms development, but unfortunately, there are no solid commercial products available yet.
Below are some snapshots of nCrunch. For more details go to www.ncrunch.net:
1) By clicking on a dot you can see a list of all tests covering that line, passing and failing.
2) By clicking on a “x” you can see where the code failed
3). The test’s assertion failure is clearly seen below:
4) Compilation errors are indicated in a following windows:
NCrunch is being actively developed and maintained. Give it a try!