Jeff Atwood has been talking about code review lately
It's always fun when someone else makes my arguments for me, especially when that someone is Jeff Atwood, writer of the super-popular-and-deservedly-so Coding Horror blog and principal of Stackoverflow. (Yes, I'm an off-and-on "Crackoverflow" addict, as you can see).
Jeff has praised code review in the past... and I quote (from here), "I believe that peer code reviews are the single biggest thing you can do to improve your code."
Yeah, well, that about sums it up!
Lately he's been talking about code review in the context of Stackoverflow, like how there was an encryption problem that would have been caught by another pair of eyes.
But my favorite is from four days ago where he repeats one of my favorite aspects of code review, and which I talk about in my book (page 102) -- what I called the "Ego Effect."
Every software developer has the desire to look smart and competent in the eyes of her peers. Well, OK, perhaps not every developer, but every one who cares at all about her work.
When you know you're going to get a code review, the way you write code changes instantly. You're going to be extra careful to document properly, do input validation, handle corner cases, write good tests, and think about scalability and error-handling.
Why? Because the last thing anyone wants is to be torn down during a code review! You want an airtight review -- no possible way to improve. See how awesome you are?
Say "code review" and instantly everyone in the group writes better code. Is there anything else with so strong and immediate an effect?
This works no matter what kind of code review you do! It's not about tools or process or meetings or metrics or anything -- just peer pressure.
Jeff calls the Ego Effect a "paradox in motivating developers" -- that to motivate them you have to tell them they "suck."
But that's not it. It's not telling someone "you suck" that's motivational. The motivation is that someone else might think you suck. And there's nothing paradoxical or unhealthy about wanting to look awesome.