As we continue to refactor our automated test scripts, I have been a part of a number of pull request reviews. I have also been involved in some code reviews for large changes that are coming. Code (or test) review is a very important and helpful strategy for a team to participate in and I am thankful for the many tools that have enabled this and made it a common practice. To be honest, I can’t really imagine a world where we didn’t have easy and frequent code reviewing.
But. (Could you sense that coming?)
Just because something is good and helpful, doesn’t mean it is perfect and certainly doesn’t mean we can use it in every situation without putting on our critical thinking caps. Participating in so many reviews has made me put that hat on. What kinds of things are code reviews good for, and more importantly, what are their limitations?
I think code reviews are very very helpful for fine tuning. ‘Don’t use that data type here.’ ‘Should you return this instead?’ ‘It look’s like you are missing a check here.’ Comments like this help greatly on catching mistakes and tweaking things to get the code into a good readable state.
Code reviews are great at helping us make those little adjustments that are needed to keep up the quality and maintainability, but what happens if the entire approach is wrong? What if you are reviewing something and you want to just shout out, NO you’re doing it completely backwards? We all do silly things sometimes and need to be called out on it, but do code reviews help with this? I guess in some ways they do. The fact that someone else will see the code makes us think about it differently and by putting it up for review someone might let us know we are approaching it from the wrong angle. But think about it; how likely are you to, in effect, tell someone ‘you just wasted 3 days doing something you need to delete.’ And even if you do, how effective is this form of feedback?
If we rely on code review as the first time someone else sees major new work we are doing, we are waiting too long. We need much earlier feedback on it. Does my approach make sense? Am I solving to correct problem here? Are there any considerations I’m missing? These kinds of questions need to be asked long before the code review goes up. Many of them should be asked before any code is even written. We need early communication on these kinds of things, so that we can get the feedback before we spend too much time going down a dead end road. Another consideration is that code reviews are usually text based and to have a discussion on direction and approach via a text based medium is likely to be an exercise in frustration. Some things work better with face to face discussions. The powerful tools that we have which enable easy code reviews can sometimes push us towards inefficient communication about the code. Stay aware of how your tools affect you and seek to do what make sense and not just what is easy.
I have been able to participate in more code reviews lately. Code reviews are an important part of testing and so I’m glad to be included in these, but there is still lots of testing work to do before the code review and I will be trying to get more testing input happening then. I guess it is my lot in life to celebrate the small victories (more code reviews – yay!) and then push on to the next thing. Never stop improving!
Thanks great blog ppost
LikeLike