code review for beginners and experts: tips & tricks · • limit time for code review • look...

15
Code review for Beginners and Experts: Tips & Tricks Łukasz Kąkol

Upload: others

Post on 02-Aug-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Code review for Beginners and Experts: Tips & Tricks · • Limit time for code review • Look carefully for both logical and design mistakes • Test the code • Be professional

Code review for Beginners and Experts:

Tips & TricksŁukasz Kąkol

Page 2: Code review for Beginners and Experts: Tips & Tricks · • Limit time for code review • Look carefully for both logical and design mistakes • Test the code • Be professional

Who am I?• Software Engineer

• Technical Team Leader

• Author of "Idiomatic Python Performance" (Apress)

• Speaker @ EuroPython, PyCon UK, PySS & local meetups

• Pythonic code vs. performancehttp://lukkol.pl/performance/ep2018

• Brace yourself, python2 is retiringhttp://lukkol.pl/python3/pyconuk2018

Page 3: Code review for Beginners and Experts: Tips & Tricks · • Limit time for code review • Look carefully for both logical and design mistakes • Test the code • Be professional

Agenda

• Introduction

• General tips & tricks

• Different perspectives

• Q&A / discussion

Page 4: Code review for Beginners and Experts: Tips & Tricks · • Limit time for code review • Look carefully for both logical and design mistakes • Test the code • Be professional

Introduction

Page 5: Code review for Beginners and Experts: Tips & Tricks · • Limit time for code review • Look carefully for both logical and design mistakes • Test the code • Be professional

What is the code review?• Software quality assurance step

• Reading and analyzing source code

• Performed by human

• Not done by author*

• Not done by manager

• Everyone in the teamshould both get and give code reviews

Page 6: Code review for Beginners and Experts: Tips & Tricks · • Limit time for code review • Look carefully for both logical and design mistakes • Test the code • Be professional

Purpose of the code review• Finding defects

• Finding better solutions

• Quality at early stage

• Improving code quality

• Code ownership

• Knowledge transfer

• Reduces bus factor

Page 7: Code review for Beginners and Experts: Tips & Tricks · • Limit time for code review • Look carefully for both logical and design mistakes • Test the code • Be professional

General tips & tricks

Page 8: Code review for Beginners and Experts: Tips & Tricks · • Limit time for code review • Look carefully for both logical and design mistakes • Test the code • Be professional

Tooling

• Use builtin code review tools

• Use code style checking tools (pylint, pyflakes, pycodestyle, etc.)

• Use code formatting tool (black)

• Set up Continuous Integration

• Add pre commit hook

Page 9: Code review for Beginners and Experts: Tips & Tricks · • Limit time for code review • Look carefully for both logical and design mistakes • Test the code • Be professional

Tips & tricks for author• Be the first reviewer

• Keep changes small

• Annotate most important changes

• If code is too complicated,walk through it with reviewer

• If you disagree with the reviewer,take the discussion offline(remember about summarizing comment)

Page 10: Code review for Beginners and Experts: Tips & Tricks · • Limit time for code review • Look carefully for both logical and design mistakes • Test the code • Be professional

Tips & tricks for reviewer

• Read the ticket

• Take your time

• Limit time for code review

• Look carefully for both logical and design mistakes

• Test the code

• Be professional and leave constructive feedback

Page 11: Code review for Beginners and Experts: Tips & Tricks · • Limit time for code review • Look carefully for both logical and design mistakes • Test the code • Be professional

Different perspectives

Page 12: Code review for Beginners and Experts: Tips & Tricks · • Limit time for code review • Look carefully for both logical and design mistakes • Test the code • Be professional

Author perspectivesBeginner / Newcomer Expert

Page 13: Code review for Beginners and Experts: Tips & Tricks · • Limit time for code review • Look carefully for both logical and design mistakes • Test the code • Be professional

Reviewing beginner's code

• Be polite and professional

• Explain clearly what the mistake is about

• Explain why is it better your way

• Show them your appreciation

Page 14: Code review for Beginners and Experts: Tips & Tricks · • Limit time for code review • Look carefully for both logical and design mistakes • Test the code • Be professional

Reviewing expert's code

• Quidquid latine dictum sit, altum videtur

• Don't take the code as perfect

• Fountain of information

• Don't be afraid to ask questions

Page 15: Code review for Beginners and Experts: Tips & Tricks · • Limit time for code review • Look carefully for both logical and design mistakes • Test the code • Be professional

Thank you!

Idiomatic Python Performance Stay tuned - early 2020

http://bit.ly/2O4Kk0X

Feedback

http://lukkol.pl/ep2019-code-review

Slides