The Best Way to Keep Your Product Moving Forward
There are so many tools available today that claim to
magically clean up your code. They slice, they dice, and they magically solve
all your problems. Sadly, as most of us know, writing good code is hard work.
But writing bad code is nearly impossible. There are no tools that can
magically solve this chasm (no matter what the tool vendors tell you!), but
there is one simple tool that can do a pretty good job of keeping you in the
first camp.Continuous integration is a pretty simple idea. Set up a
program to watch your source code. When anyone changes anything, your CI system
compiles immediately. If the compile passes, then any automated tests you have
are run. Finally, the results are published.
Simple right? But why is it so powerful?
Continuous integration is a reverse credit card. A credit card lets you buy something big today, and pay it back little by little. Credit cards have a dirty little secret though... compound interest. You pay back much, much more than you borrowed. It's always cheaper to pay cash if you can afford it.
When you use a CI system, the opposate is true. You can either make little payments every day, or you can wait until the end and make one huge payment. Unfortunately that huge payment has all the compound interest added to it! By waiting until the end, you're paying more... a lot more!
This is due to the "dark time" between when a developer writes code and when they merge it into the code everyone else has written. If you merge all the code together every day, or even a few times a week, the changes are small and fairly painless. But not if you wait.
If you wait, your changes grow. The longer you wait the more code you write (hopefully!). And the more code everyone else on your team writes. So at the end of the month, when you finally are forced to combine all those changes, the collisions are immense. Developers work on the same files, sometimes on the same lines... other times functionality that one developer depended on having in place is changed (I mean "improved") by another developer. The mutually exclusive changes wreak havoc.
The time between the writing of the code and the merge, compile, and testing of everyone's code, is when you can't see what's happening. Are your changes colliding with someone else's? Did someone change something you need? You just can't see it yet... it's all dark. And it remains dark until you get it all together.
A CI tool helps developers learn the cadence of "write one thing," then "check it in." This works much better than "write one thing.... then another, then another, then another...", and then "dedicate hours or days to merging." And we haven't even started talking about the benefits of having an automated test run after every commit!
Find problems as quickly as possible, while the fixes are still small. Turn the steering wheel before the car is actually in the ditch. It's the easiest time to fix a problem!
Here are a few CI product links to get you started.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)