Code Review
Cris Uy
Agenda
• Goals
• Types of Code Review
• Tips for Developers during Code Review
• Tips for Reviewers during Code Review
• General Guidelines
• Control Structures
• Error Handling
• Resource Leaks
• Performance
• Maintainability and Reusability
Goal
• To spot and fix defects early in the process
• Helps to maintain a level of consistency in
design and implementation
• Better shared understanding of the code
base as team members learn from each
other
Types of Code
Review
Formal Code Review
• Involves software developers meeting
together and reviewing relevant code line by
line many times taking the opportunity to
analyze printed copies of the materials
Peer Code Review
• Can be done over the shoulder where the
reviewer looks over the author’s shoulder as
the other goes through the code
• Or can be done via email or version control
system like Git and online conference
Tips for Developers
during Code Review
• The primary reviewer is the author.
• You
• Create a checklist for yourself of the
things that the code reviews tend to
focus on
• Understand and accept that you
will make mistakes
• No matter how much your
knowledge is, someone else will
always know more than you
• Don’t rewrite code without
consultation
• The only constant thing in this
world is change
• Fight for what you believe, but
gracefully accept defeat
• Please note that review meetings
are not problem solving meetings
• Helping to maintain the coding
standards
Tips for Reviewers
during Code Review
• Critique code instead of people – be
kind to the coder, not to the code
• Treat people who know less than
you with respect, deference and
patience
• Ask questions rather than make
statements
• Avoid the why questions
• Remember to praise
• Make sure you have good coding
standards to reference
• Remember that there is often more
than one way to approach a
solution
• You should not rush through a code
review – but also, you need to do it
promptly
• Review fewer than 200 – 400 lines
of code at a time
General Guidelines
• Is the code following coding
guidelines and naming
conventions?
• Reviewer should have a reference
for coding guidelines and
conventions
• Are all compiler warnings fixed?
• Are there leftover code for
testing/development?
• Is the code complexity under the maximum
allowable threshold for a given metric?
• *a class is less than 500 lines
• *a method does not contain more than 15
control structures
Control Structures
• Check for infinite loops?
• Does the loop iterate the correct number of
times?
Error Handling
• Does the code check for null exceptions?
• Does the code check for array out of bounds
exceptions?
Resource Leaks
• Are all allocated memory freed?
• Do all classes perform thorough cleanup on
its destructor (dealloc)?
• Are all notification observers, event listeners,
message receivers or gesture recognizers
removed when not needed?
• Does the code accurately keep track of
reference counting?
Performance
• Are you using blocking system calls when
performance is involved?
• Will the same data be reloaded often?
• Will caching data improve performance?
• Is a large number of big objects being
created and destroyed in a small amount of
time?
• Will reusing objects improve performance?
• Was this optimization really needed?
Maintainability and
Reusability
• Is the code using magic numbers and magic
strings?
• Does the code comply with the DRY (Don’t
Repeat Yourself) principle?
Thank you!

Code Review for iOS