1 of 20

I Am Code Review

(And So Can You!)

2 of 20

2

What IS NOT a Code Review?

3 of 20

What are Code Reviews?

  • An opportunity for a reviewer to analyze completed code before it is merged into the mainline branch
  • We are primarily looking for mistakes (bugs), security vulnerabilities, and confusing or difficult to maintain code

3

4 of 20

Why Do Code Reviews?

  • Find and fix bugs
  • Improve the quality of our software

4

The Economic Impacts of Inadequate Infrastructure for Software Testing

National Institute of Standards and Technology, May 2002

https://www.nist.gov/sites/default/files/documents/director/planning/report02-3.pdf

5 of 20

Why Do Code Reviews? (cont)

  • Ensure code is correct, understandable, and maintainable
  • Keep security on our minds
  • Share knowledge and experience
  • Raise team standards
  • Keep documentation up-to-date
  • Be able to work on each other’s projects

5

6 of 20

Conducting a Code Review

Author:

  • Test your code first!!!
  • Use your tools to maintain the boring stuff (whitespace, style guide, linter, etc)
  • Keep reviews as small as possible, under 200-400 lines
  • Include details on the contents of the changes (user stories, feature set list, bug report, etc)

6

7 of 20

Conducting a Code Review

Reviewer:

  • Review immediately if possible
  • Limit review time to half an hour
  • Don’t block unless there is a bug
  • Frame feedback as requests, not commands
  • Provide code examples, references, links, etc when applicable
  • Review Unit Tests and Documentation as well

7

8 of 20

Keep It Professional

  • Code reviews are a part of the job. We should be courteous and professional to one another.
  • We all make mistakes, and we all have room to grow. This is an opportunity to learn.
  • Don’t be afraid to ask for clarification, or pass a review to someone else if your unsure.

8

9 of 20

9

Common Issues

Vague or repeated variable and function names

10 of 20

10

Common Issues

Not utilizing types in Typescript

11 of 20

11

Common Issues

Not utilizing types in Typescript

Improved by adding the User type

Bonus advantage: IDE parameter hints in realtime

12 of 20

12

Common Issues

Insufficient or nonexistent error handling

Insufficient:

Much Improved:

13 of 20

13

Common Issues

Misusing observables

14 of 20

14

Common Issues

Duplicated code

15 of 20

15

Common Issues

Too much going on in one file.

16 of 20

16

Let’s Review Some Code!

Example 1

17 of 20

17

Let’s Review Some Code!

Example 2

18 of 20

18

Let’s Review Some Code!

Example 3

19 of 20

19

Let’s Review Some Code!

Example 4

20 of 20

Resources

20