Should You Have a Code Nazi?
Code reviews never happen often enough. There's rarely enough time to mentor junior developers. Pair-programming doesn't happen as often as it should. Should teams create a rotating-role of Code Nazi? Someone who'd job is to look for potential problems and ensure they get fixed.
Note, I'm not talking about someone to look for curly-brace placement and similar minutiae; tools can do that.
Honestly, this would not be necessary if code reviews happened often enough; if all code written was peer-reviewed. In the real world, code reviews don't happen frequently enough and they rarely cover a significant portion of the code written/edited. Constant vigilance could help catch problems before they become big issues.
One way to look at this is as a form of Incremental Code Review. Where we basically want to make sure the code base is reviewed constantly istead of waiting till the end when changes will be costly. I highly recommend reading Brian's post on the topic.
Culture of Quality
The act of constantly focusing on code quality can help to build a Culture of Quality in the team. This can help all aspects of development to improve. NNPPs can get turned around by the simple act of living in this culture on a day to day basis. When the team sees (daily) the importance of quality, the morale improves, attitudes get better. Everyone wants to feel like they are working on good stuff.
The constantly changing role and stream of communication will help build communication between team members. Better communication will mean less wasted time, more code re-use, and a better product overall.
Mentoring Junior Developers
By rotating the role through both senior and junior developers, knowledge transfer can take place. When senior developers are in the role, they can guide junior developers through better practices. When a junior developer is in the role, they get an opportunity to review code written by more experienced developers. Even senior developers can learn a thing or two when reviewing the code of their peers.
Tools Can Help But Should Not Drive
Static analysis tools can be very helpful. Just Keep in mind that there will be plenty of false positives. Just be sure to use the tool to help find problematic code, don't be a slave to the reports generated by the tool. Think of them as a way to find a starting point.
Keys to Success
- Rotate the role among ALL developers
- Don't expect instant results
- Use tools to help, not drive
- The first to complain gets the role first