views:

33

answers:

2

I religiously go through all of my code before I check it in and do a diff of the before and after code and read through it and make sure I undersatnd the changes. Usually I end up having to add comments, amend variable names, amend algorithms, amend code, retest things, discuss with other developers about their code, add new bugs/issues, but I very rarely end up doing the checkin immediately.

I do notice however that alot of developers these days seem to check their code in and think that when the build breaks that it is enough, then they go back and look at their changes. This is one of the things about continuous build systems that I definitely do not like, in that sometimes I think developers stop thinking about their code enough.

What best practices are there for ensuring only quality code goes into continuous build systems?

+1  A: 

Team Foundation Server has something called pre checkin validation.

Arve
I tried to go to the site, it wasn't explained so clearly. Have you used it Arve?
Zubair
No, I basically attened som event from Microsoft where they explained that this would be supported in the new version (2010) of Team Foundation Server
Arve
Ok, thanks. I guess once it is used in the real world we can find out if it improves code quality
Zubair
+1  A: 

I do notice however that alot of developers these days seem to check their code in and think that when the build breaks that it is enough, then they go back and look at their changes.

In my opinion, using the continuous build for "verification" purpose is indeed a bad practice, developers should always try to not commit bad code that can affect the team and interrupt the work (the why is so obvious that if you don't get that, just look for another job). So, if your CI engine doesn't offer Pre-tested commit (like TeamCity, Team Foundation Server as I just saw, maybe Hudson one day, etc), you should always sync/build/sync (and rebuild if necessary) locally before to commit. Not doing this is laziness and not respectful of the team.

What best practices are there for ensuring only quality code goes into continuous build systems?

  • Just in case, remind why breaking the build is bad: bad code potentially affects the whole team and interrupts the work (sigh).
  • If you can get tool support (see the mentioned solutions above), get it.
  • If not, document the right workflow: 1. sync 2. build locally 3. sync 4. back to 2 if required 5. commit. Make this visible so that there is no excuses.
  • If this is an option, use something like (or similar to) the Hudson's Continuous Integration Game plugin. This can make things more fun.

I've seen people using a light financial "penalty" for broken build but I don't really like this idea. First, we should be able to behave as responsible adults. Second, the obtained result was that people started to delay commits (which at the end was the opposite of the expected benefit).

Pascal Thivent