Why Code Reviews Are Great Learning Tools

What is a code review?

A code review is the examination of your code and feedback on your code by a peer, or coach. Code reviews can take place online (for instance by using Github), or in person – offline.

code reviews are awesome

How does a code review work?

Finished a piece of code (or a feature)? Create a patch or pull request and send or assign this to a peer, coach, or mentor. They will look at your code and make comments, add questions, or give suggestions.

Alternatively, you could walk someone through your code and explain them what is going on line by line, or more generally on an architectural level. This is aptly called a code walkthrough.

Why have a code review?

Feedback

In general, code reviews are great ways to get feedback on your code and then use this feedback to improve the code. For instance, you may have made a typo or introduced a bug that you are unaware of, maybe a second pair of eyes will help you catch it. Alternatively, a reviewer can give you feedback on style, or give you tips on how to write the same thing in a more efficient way.

For learners, this feedback is invaluable. It allows you to encertain that you truly understood the code you wrote and immediately correct errors, or style mistakes. That way you are far less likely to adopt bad habits and practices.

Knowledge transfer

Within teams, code reviews can help you share your knowledge of the code base. In a learning environment code reviews are a good way to update your coach on your progress. Or, alternatively, if your code is reviewed by another learner, they will end up learning something new!

Commit to write better code

Knowing that your code will see the light of day will make you more likely to think twice before committing something. It could motivate you to take a second look at your code and see if it would hold up under scrutiny. That said, don't let perfectionism get the better of you – there is a balance!

Why is this important for learning? As you are learning new languages or frameworks, it's often tempting to just make it work and care less about whether your approach is indeed the best one. If you know someone will go through your code you are far more likely to reflect on the code you wrote.

Anything to add? Discuss below!

About the Authors

Anouk Ruhaak

Hackership Organiser. Economist turned freelance iOS developer. Former Hackership learner. Currently exploring web development with React and Twisted. Love discovering new fields and topics, which include functional programming, cryptography and security. anouk at Hackership dot org

Discussion