Does your team do code reviews? If not why? Are you afraid or worried about something? If they do, awesome. Do you want to learn how to improve the process? This session we will dive into the art of the Code Review. We will learn how to avoid pitfalls and how to reap the rewards of this awesome
2. PLAN OF ACTION
Why do Code Reviews?
What Makes a GOOD Code Review?
What Makes a BAD Code Review?
Explore different TYPES of Code Reviews!
Rules of ENGAGEMENT for Code Reviews!
3. WHAT IS A CODE REVIEW?
An examination of code which is intended to find
overlooked mistakes which can cause future bugs. With
the goal to improve overall quality of code and to share
knowledge
10. JAVASCRIPT CHECKLIST IDEAS
Does is pass linting?
Is the code well factored?
Using Promises (or async) vs callbacks
Are variables scoped correctly?
No use of `var`, use Const or Let as appropriate
Has Unit test coverage
37. THINGS TO LOOK FOR IN CODE REVIEWS
Simplicity over cleverness
38. THINGS TO LOOK FOR IN CODE REVIEWS
Following Existing Patterns
Editor's Notes
Questions to the audience
Who does code reviews?
When do you do them?
Who enjoys doing them?
Who has had a bad experience with them?
- Multiple reasons but all of them revolve about betterment of the code and the team
We all right code, none of us right code with the intent to introduce bugs, but it just happens.
Having more eyes on the code will help us to reduce possible bugs
When working on business applications we are normally working on non-trival code bases. Often times these applications are too large to fully commit to memory
Sometimes when developing code we think we found the best way to solve an issue. But often times there may be a simpler way. There may be a more performant way.
All teams have code that only 1 person wants to, or can maintain. Code Reviews can help remove this
Allows others to be able to help support
We now know the WHY, lets learn about the what
How can you perform a review without having an idea of what you are looking for
Create a checklist for different type of code.
- UI code
- API code
- Javascript vs compiled languages
Use the checklist to be consistant
If doing a group review make sure to setup a time box. This will force you to be on point and not get lost in the weeds
Don’t just go through the motions
Stay engaged
Act as if you care
Treat the review as you would hope they would treat yours
The review is about the code, not the CODER
Too many times I hear people who hate code reviews and it is due the fact that they have felt personally attacked in prior review sessions
Use Positive words
Be just as willing to praise as you are to knock down
Give suggestions but avoid telling people they are doing something ‘wrong’
There must have been a reason the code was written. Attempt to see the coders POV.
Seek to understand
Assume the code was written with good intent
Ask questions about the thought process – seek to understand
Ask questions about alternatives solutions
Sadly it is far to easy to experience a bad code review. But why?
Nothing good tends to happen when you wing it
Never
Always
You Must
Unless your team has an established and documented styles document it is often not worth debating style. Everyone has their own style and often times there is no meaningful difference between styles.
- Suggest you leave feedback as close to the code as possible. If possible create comments in the PR
Do all comments/suggestions need to be implemented
If implementing comments/feedback are they done in the same PR or as separate PR?
I suggest same PR if related to code under review
I suggest new PR if enhancements
We know what makes good and bad reviews. Lets turn to talking about what to look for while doing our reviews
Having another set of eyes on the code will allow things to be found
Safe to say that everyone of us have had a problem that we struggled to solve but the second we asked someone else for help we saw the solution. Code reviews can do the same thing
Lets face it, sometimes we write overly complicated code without meaning to. This code could work, but is likely a maintenance issue going forward. CR’s can help find and elimate this type of code.
PII
PFI
Hippa
Data Corruption (sql injection)
As yourself, is this code easy to read?Will the ‘next guy’ know what is intended?
Often times when dealing with larger applications comment patterns will emerge. Make sure your solution follows these patterns when possible.
It is ok to not follow existing patterns, but make sure you have a reason