178
PHP[TEK] 2018 Wi : Sheraton Conference Pass: phptek2018 Twitter: #phptek Rate the Talks https://joind.in/event/phptek-2018

Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

PHP[TEK] 2018

Wifi: Sheraton Conference

Pass: phptek2018

Twitter: #phptek

Rate the Talks https://joind.in/event/phptek-2018

Page 2: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

EFFECTIVE CODE REVIEW

DAVE LIDDAMENT

Page 3: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WHY THIS TALK?

EFFECTIVE CODE REVIEW REDUCES OVERALL COST OF SOFTWARE DEVELOPMENT

Page 4: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

Thanks to Our Sponsors

Page 5: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

EFFECTIVE CODE REVIEW

AGENDA

▸ Why

▸ Code quality

▸ What is code review

▸ Benefits

▸ Implementation

▸ Tips

▸ Integrating code review into project workflow

Page 6: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

Dave Liddament Lamp Bristol

Organize: - PHP-SW user group - Bristol PHP Training

@daveliddament

Page 7: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and
Page 8: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and
Page 9: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

Page 10: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

Page 11: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

Page 12: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

Page 13: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and
Page 14: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and
Page 15: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and
Page 16: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and
Page 17: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and
Page 18: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

Page 19: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

Page 20: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

Page 21: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

Page 22: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and
Page 23: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

??

Page 24: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

☀?

?

Page 25: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

Page 26: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

Page 27: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

MORAL OF THE STORY

WHAT DID WE LEARN?

▸ We all make mistakes.

▸ If the mistakes are spotted and rectified quickly the consequences of the mistakes are minimal.

▸ We want to make mistakes easy to spot.

Page 28: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WHAT ABOUT SOFTWARE DEVELOPMENT?

Page 29: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WHAT ABOUT SOFTWARE DEVELOPMENT?

▸ We all make mistakes.

▸ If the mistakes are spotted and rectified quickly the consequences of the mistakes are minimal.

▸ We want to make mistakes easy to spot.

Page 30: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

COST OF A BUG

Cost

DESIGN WRITING CODE

TEST RELEASE MAINTENANCE

FIND BUGS SOONER

Page 31: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

COST OF A BUG

Cost

DESIGN WRITING CODE

TEST RELEASE MAINTENANCE

FIND BUGS SOONER

Page 32: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

EFFECTIVE CODE REVIEW REDUCES OVERALL COST OF SOFTWARE DEVELOPMENT

Page 33: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE QUALITY

EFFECTIVE CODE REVIEW REQUIRES…

Page 34: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE QUALITY

EFFECTIVE CODE REVIEW REQUIRES…

Page 35: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE QUALITY

EFFECTIVE CODE REVIEW REQUIRES…

Page 36: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE QUALITY

EFFECTIVE CODE REVIEW REQUIRES…

Page 37: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW IS THE SYSTEMATIC EXAMINATION OF SOURCE CODE…

Wikipedia

WHAT IS CODE REVIEW

Page 38: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

IT IS INTENDED TO FIND MISTAKES OVERLOOKED IN SOFTWARE DEVELOPMENT, IMPROVING THE OVERALL QUALITY OF SOFTWARE.

Wikipedia

WHAT IS CODE REVIEW

Page 39: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WHAT IS CODE REVIEW

HOW IS IT DONE

Page 40: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WHAT IS CODE REVIEW

HOW IS IT DONE

Page 41: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WHAT IS CODE REVIEW

HOW IS IT DONE

Page 42: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

Page 43: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

WHAT ARE DEFECTS?

Page 44: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

WHAT ARE DEFECTS?

Bugs

Page 45: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

WHAT ARE DEFECTS?

Bugs

Evolvability

Page 46: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

AN EVOLVABILITY DEFECT IS…

Code that makes code base less compliant with standards, more error prone, or more difficult to modify, extend or understand.

Page 47: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

WHAT ARE DEFECTS?

Bugs

Evolvability [1, 2]

Page 48: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

EVOLVABILITY IS IMPORTANT

▸ Low evolvability costs money:

▸ New features took 28% longer to implement [3]

▸ Fixing bugs took 36% longer [3]

▸ Software structure may account for 25% of total maintenance costs [4]

Page 49: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

COST TO DEVELOP SIMILAR SIZED FEATURE OVER TIME

Page 50: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

Cost

Time into project

COST TO DEVELOP SIMILAR SIZED FEATURE OVER TIME

Page 51: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

Cost

Time into project

COST TO DEVELOP SIMILAR SIZED FEATURE OVER TIME

Page 52: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

Cost

Time into project

COST TO DEVELOP SIMILAR SIZED FEATURE OVER TIME

Page 53: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

TAKE AWAY

▸ The majority of code review comments will not be “bugs”.

▸ Most comments will be code improvements.

▸ Lower technical debt. Lower overall cost.

▸ Studies back this up.

▸ Remember to sell the right metric to management.

Page 54: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

SECURITY REVIEW

Page 55: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

SECURITY REVIEW

▸ Writing sensitive data to logs (e.g. password)

Page 56: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

SECURITY REVIEW

▸ Writing sensitive data to logs (e.g. password)

▸ Bugsnag / error log reporting

Page 57: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

SECURITY REVIEW

▸ Writing sensitive data to logs (e.g. password)

▸ Bugsnag / error log reporting

▸ Files that shouldn’t be there? (e.g. malware)

Page 58: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

SECURITY REVIEW

▸ Writing sensitive data to logs (e.g. password)

▸ Bugsnag / error log reporting

▸ Files that shouldn’t be there? (e.g. malware)

▸ OWASP top 10

Page 59: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

SECURITY REVIEW

▸ Writing sensitive data to logs (e.g. password)

▸ Bugsnag / error log reporting

▸ Files that shouldn’t be there? (e.g. malware)

▸ OWASP top 10

▸ OWASP top 10 cheat sheet

Page 60: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

SECURITY REVIEW

▸ Writing sensitive data to logs (e.g. password)

▸ Bugsnag / error log reporting

▸ Files that shouldn’t be there? (e.g. malware)

▸ OWASP top 10

▸ OWASP top 10 cheat sheet

▸ Not / weakly hashing passwords

Page 61: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

SECURITY REVIEW

▸ Writing sensitive data to logs (e.g. password)

▸ Bugsnag / error log reporting

▸ Files that shouldn’t be there? (e.g. malware)

▸ OWASP top 10

▸ OWASP top 10 cheat sheet

▸ Not / weakly hashing passwords

▸ Rolled your own authentication / hashing / encryption algorithms

Page 62: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

SPREAD THE KNOWLEDGE

Page 63: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

NO MORE SILOS

Page 64: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

NO MORE SILOS

XXX

Page 65: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

NO MORE SILOS

XXX

Page 66: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

NO MORE SILOS

XXX

Page 67: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

NO MORE SILOS

XXX

Page 68: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

MENTORING

Page 69: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

Rate

of i

ntro

duci

ng b

ugs

Experience / Skill

SKILL AND EXPERIENCE VS BUGS

Page 70: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

YOU’RE BEING WATCHED!

Page 71: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

YOU’RE BEING WATCHED!

[5]

Page 72: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW BENEFITS

BENEFITS

▸ Reduce defects

▸ Studies that back this up

▸ Find security vulnerabilities

▸ Spread knowledge

▸ Mentoring

▸ Peer pressure improves code quality

Page 73: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

EFFECTIVE CODE REVIEW REDUCES OVERALL COST OF SOFTWARE DEVELOPMENT

Page 74: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

IMPLEMENTATION

Page 75: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

IMPLEMENTATION

Page 76: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

IMPLEMENTATION

WE CAN AUTOMATE

Page 77: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

IMPLEMENTATION

WE CAN AUTOMATE

▸ Tests

Page 78: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

IMPLEMENTATION

WE CAN AUTOMATE

▸ Tests

▸ Code style (php-cs-fixer)

Page 79: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

IMPLEMENTATION

WE CAN AUTOMATE

▸ Tests

▸ Code style (php-cs-fixer)

▸ Lint (php, yaml, twig, doctrine, composer)

Page 80: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

IMPLEMENTATION

WE CAN AUTOMATE

▸ Tests

▸ Code style (php-cs-fixer)

▸ Lint (php, yaml, twig, doctrine, composer)

▸ Static analysis (Psalm, PHPStan, Phan)

Page 81: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

IMPLEMENTATION

WE CAN AUTOMATE

▸ Tests

▸ Code style (php-cs-fixer)

▸ Lint (php, yaml, twig, doctrine, composer)

▸ Static analysis (Psalm, PHPStan, Phan)

▸ 3rd party security checks (sensiolabs/security-checker)

Page 82: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

IMPLEMENTATION

DO THE TESTS TEST THE REQUIRED FUNCTIONALITY?

Page 83: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

IMPLEMENTATION

REMEMBER THE NAVIGATION COOKIE?

Page 84: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

IMPLEMENTATION

ARE THE TESTS ADEQUATE?

Page 85: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

IMPLEMENTATION

IS THIS ENOUGH TESTING?

Scenario: Navigation at T junction in a cave Given: I am coming up to a T. When: Before I pass the T junction. Then: I should drop a cookie

Page 86: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

IMPLEMENTATION

IS THIS ENOUGH TESTING?

Scenario: Navigation at T junction in a cave Given: I am coming up to a T. When: Before I pass the T junction. Then: I should drop a cookie on the exit side.

Page 87: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

IMPLEMENTATION

HOW MANY TESTS DO WE NEED?

/** * @param int $id * @return bool * @throws NotFoundException */ public function isAllowed(int $id): bool { .. some implementation .. }

/** * @param int $id * @return bool * @throws NotFoundException */ public function isAllowed(int $id): bool { .. some implementation .. }

Page 88: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

IMPLEMENTATION

WILL I UNDERSTAND THIS CODE IN 6 MONTHS TIME?

Page 89: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

“THE RATIO OF TIME SPENT READING VERSUS WRITING IS WELL OVER 10 TO 1. WE ARE CONSTANTLY READING OLD CODE AS PART OF THE EFFORT TO WRITE NEW CODE. … [THEREFORE,] MAKING IT EASY TO READ MAKES IT EASIER TO WRITE.”

Robert C. Martin (Clean Code)

COST OF WRITING CODE CODE

Page 90: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WILL I UNDERSTAND THE CODE IN 6 MONTHS TIME?

WHAT DOES THIS CODE DO?

$userFields = [ 'Username', 'Email', 'FirstName', 'LastName', 'Phone', ];

foreach ($userFields as $key) { if ($userDetails->{'get'.$key}()) { $user->{'set'.$key}($userDetails->{'get'.$key}()); } }

Page 91: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WILL I UNDERSTAND THE CODE IN 6 MONTHS TIME?

WHAT DOES THIS CODE DO? (2)

if ($userDetails->getUsername()) { $user->setUsername($userDetails->getUsername()); } if ($userDetails->getEmail()) { $user->setEmail($userDetails->getEmail()); } if ($userDetails->getFirstName()) { $user->setFirstName($userDetails->getFirstName()); } if ($userDetails->getLastName()) { $user->setLastName($userDetails->getLastName()); } if ($userDetails->getPhone()) { $user->setPhone($userDetails->getPhone()); }

Page 92: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WILL I UNDERSTAND THE CODE IN 6 MONTHS TIME?

/** * Represents a location in the UK. *(eg city, town, village) */ class Location {

/** * @return string URL */ public function getUrl(): string {

return $this->url; }

Page 93: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WILL I UNDERSTAND THE CODE IN 6 MONTHS TIME?

WHAT IS URL?/** * Represents a location in the UK. *(eg city, town, village) */ class Location {

/** * @return string URL */ public function getUrl(): string {

return $this->url; }

Page 94: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WILL I UNDERSTAND THE CODE IN 6 MONTHS TIME?

WHAT IS URL?/** * Represents a location in the UK. *(eg city, town, village) */ class Location {

/** * @return string URL */ public function getUrl(): string {

return $this->url; }

Page 95: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WILL I UNDERSTAND THE CODE IN 6 MONTHS TIME?

if ($agent->getType() === 1) {

… do something …

}

Page 96: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WILL I UNDERSTAND THE CODE IN 6 MONTHS TIME?

WHAT DOES 1 MEAN?

if ($agent->getType() === 1) {

… do something …

}

Page 97: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

IS THE CODE AS OBVIOUS AND EXPLICIT AS IT POSSIBLY CAN BE

HOW DO WE MAKE THIS MORE OBVIOUS

class MarketingCampaign {

public function addAddress($address) { .. some implementation .. }

}

Page 98: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

IS THE CODE AS OBVIOUS AND EXPLICIT AS IT POSSIBLY CAN BE

HOW DO WE MAKE THIS MORE OBVIOUS (2)

class MarketingCampaign {

public function addEmailAddress($emailAddress) { .. some implementation .. }

}

Page 99: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

IS THE CODE AS OBVIOUS AND EXPLICIT AS IT POSSIBLY CAN BE

HOW DO WE MAKE THIS MORE OBVIOUS (3)

class MarketingCampaign {

/** * Adds email address, person will then be * messaged as part of the campaign. */ public function addEmailAddress($emailAddress) { .. some implementation .. }

}

Page 100: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

IS THE CODE AS OBVIOUS AND EXPLICIT AS IT POSSIBLY CAN BE

HOW DO WE MAKE THIS MORE OBVIOUS (4)

class MarketingCampaign {

/** * Adds email address, person will then be * messaged as part of the campaign. */ public function addEmailAddress(

string $emailAddress): void { .. some implementation .. }

}

Page 101: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

IS THE CODE AS OBVIOUS AND EXPLICIT AS IT POSSIBLY CAN BE

HOW DO WE MAKE THIS MORE OBVIOUS (4)

class MarketingCampaign {

/** * Adds email address, person will then be * messaged as part of the campaign. */ public function addEmailAddress(

EmailAddress $emailAddress): void { .. some implementation .. }

}

Page 102: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

QUESTIONS TO ASK IN CODE REVIEW

ARE WE FOLLOWING PROJECT CONVENTIONS?

Page 103: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

ARE WE FOLLOWING PROJECT CONVENTIONS

interface LocationRepository {

public function findClosestTo($point);

public function findByName($name);

public function findBySlug($slug);

public function searchForLocation($name, $type);

public function findAllByType($type);

}

Page 104: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

ARE WE FOLLOWING PROJECT CONVENTIONS

INCONSISTENT METHOD NAMEinterface LocationRepository {

public function findClosestTo($point);

public function findByName($name);

public function findBySlug($slug);

public function searchForLocation($name, $type);

public function findAllByType($type);

}

Page 105: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and
Page 106: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

QUESTIONS TO ASK IN CODE REVIEW

DO THE COMMENTS MATCH THE CODE?

Page 107: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

QUESTIONS TO ASK IN CODE REVIEW

HAS DEFENSIVE CODING BEEN USED?

Page 108: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

HAS DEFENSIVE CODING BEEN USED

/** * Set status (one of started|finished|quit) * * @param string $status */ public function setStatus(string $status): void { $this->status = $status; }

/** * Set status (one of started|finished|quit) * * @param string $status */ public function setStatus(string $status): void { $this->status = $status; }

Page 109: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

HAS DEFENSIVE CODING BEEN USED

MISSING CHECK THAT STATUS IS A VALID VALUE

/** * Set status (one of started|finished|quit) * * @param string $status */ public function setStatus(string $status): void { $this->status = $status; }

/** * Set status (one of started|finished|quit) * * @param string $status */ public function setStatus(string $status): void { $this->status = $status; }

Page 110: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

QUESTIONS TO ASK IN CODE REVIEW

CORRECT NAMING

Page 111: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

QUESTIONS TO ASK IN CODE REVIEW

CORRECT NAMING

▸ Language for domain or project you’re working on

Page 112: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

QUESTIONS TO ASK IN CODE REVIEW

CORRECT NAMING

▸ Language for domain or project you’re working on

▸ Design patterns

Page 113: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

QUESTIONS TO ASK IN CODE REVIEW

HAS TECHNICAL DEBT BEEN DOCUMENTED?

Page 114: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

HAS TECHNICAL DEBT BEEN DOCUMENTED

ALL TODO COMMENTS MUST REFERENCE A TICKET

// TODO: Refactor to method https://trello.com/c/Aaa123

… some hacky code …

Page 115: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

QUESTIONS TO ASK IN CODE REVIEW

CAN ARCHITECTURE BE IMPROVED?

Page 116: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

QUESTIONS TO ASK IN CODE REVIEW

ARE THERE ANY BUGS?!

Page 117: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

QUESTIONS TO ASK IN CODE REVIEW

CHECK LIST

▸ Do the tests fully test the required functionality

▸ Will I understand this code in 6 months

▸ Does the code follow project conventions

▸ Is the code obvious and explicit

▸ Do comments match the code

▸ Has defensive coding been used

▸ Has technical debt been documented

▸ Can architecture be improved

▸ Are there any bugs

Page 118: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

QUESTIONS TO ASK IN CODE REVIEW

CHECK LIST: TLDR

▸ Correct tests

▸ Clean code

▸ No bugs

Page 119: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

Page 120: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

EVERYONE SHOULD CODE REVIEW

Page 121: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

ASK PROGRAMMERS TO REVIEW 10 LINES OF CODE THEY’LL FIND 10 ISSUES…

Anyone who’s done code review

CODE REVIEW TIPS

Page 122: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

ASK THEM TO DO 500 LINES THEY’LL SAY IT’S GOOD TO GO

Anyone who’s done code review

CODE REVIEW TIPS

Page 123: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

SMALL COMMITS

Page 124: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

SMALL COMMITS

Page 125: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

SMALL COMMITS

DEPRECATE: The price calculation service

Page 126: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

SMALL COMMITS

DEPRECATE: The price calculation service

ADD: Facade to 3rd party price calculation service

Page 127: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

SMALL COMMITS

DEPRECATE: The price calculation service

ADD: Facade to 3rd party price calculation service

UPDATE: Use new price calculator code

Page 128: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

SMALL COMMITS

DEPRECATE: The price calculation service

ADD: Facade to 3rd party price calculation service

UPDATE: Use new price calculator code

REMOVE: Deprecated price calculation service

Page 129: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

HOW MUCH SHOULD YOU REVIEW IN ONE GO?

▸ Fewer than 400 lines of code at a time [6]

▸ Under 500 line of code reviewed per hour [6]

▸ Max 1 hour review at a time [6]

Page 130: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

GOOD COMMITS

Page 131: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

GOOD COMMITS

▸ Small

Page 132: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

GOOD COMMITS

▸ Small

▸ Focus on one thing

Page 133: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

GOOD COMMITS

▸ Small

▸ Focus on one thing

▸ Whitespace changes into their own commits

Page 134: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

GOOD COMMITS

▸ Small

▸ Focus on one thing

▸ Whitespace changes into their own commits

▸ Reference to story, bug report, Trello/Jira card

Page 135: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

GOOD REVIEW COMMENTS

Page 136: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

GOOD REVIEW COMMENTS

▸ Don’t be an idiot. Don’t be rude

Page 137: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

GOOD REVIEW COMMENTS

▸ Don’t be an idiot. Don’t be rude

▸ Not critical of the author

Page 138: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

GOOD REVIEW COMMENTS

▸ Don’t be an idiot. Don’t be rude

▸ Not critical of the author

▸ State problem and solution

Page 139: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

GOOD REVIEW COMMENTS

▸ Don’t be an idiot. Don’t be rude

▸ Not critical of the author

▸ State problem and solution

▸ Link to Stack Overflow, blog, etc

Page 140: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

GOOD REVIEW COMMENTS

▸ Don’t be an idiot. Don’t be rude

▸ Not critical of the author

▸ State problem and solution

▸ Link to Stack Overflow, blog, etc

▸ Use: “Let’s chat”

Page 141: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

GOOD REVIEW COMMENTS

▸ Don’t be an idiot. Don’t be rude

▸ Not critical of the author

▸ State problem and solution

▸ Link to Stack Overflow, blog, etc

▸ Use: “Let’s chat”

▸ Use: “Question”

Page 142: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

GOOD REVIEW COMMENTS

▸ Don’t be an idiot. Don’t be rude

▸ Not critical of the author

▸ State problem and solution

▸ Link to Stack Overflow, blog, etc

▸ Use: “Let’s chat”

▸ Use: “Question”

▸ Compliment

Page 143: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

RECEIVING REVIEW COMMENTS

Page 144: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

RECEIVING REVIEW COMMENTS

▸ Don’t be an idiot. Don’t be rude

Page 145: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

RECEIVING REVIEW COMMENTS

▸ Don’t be an idiot. Don’t be rude

▸ Don’t take offence

Page 146: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

RECEIVING REVIEW COMMENTS

▸ Don’t be an idiot. Don’t be rude

▸ Don’t take offence

▸ Do say if you disagree

Page 147: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

RECEIVING REVIEW COMMENTS

▸ Don’t be an idiot. Don’t be rude

▸ Don’t take offence

▸ Do say if you disagree

▸ Compliment

Page 148: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CODE REVIEW TIPS

CODE REVIEW TIPS

▸ Get everyone involved

▸ Keep commits small

▸ Be constructive in code review comments

▸ Link to relevant bugs / stories / Trello cards

Page 149: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

SETUP GITHUB

CODE CAN ONLY BE DEPLOYED IF:

▸CI passes

▸Code review passes

Page 150: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

SETUP GITHUB

Page 151: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

SETUP GITHUB

Page 152: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

SETUP GITHUB

Page 153: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

SETUP GITHUB

Page 154: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

SETUP GITHUB

Page 155: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

SETUP GITHUB

Page 156: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

SETUP GITHUB

Page 157: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

SETUP GITHUB

Page 158: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

SETUP GITHUB

Page 159: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

SETUP GITHUB

Page 160: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

SETUP GITHUB

Page 161: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

SETUP GITHUB

Page 162: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

EFFECTIVE CODE REVIEW

INTEGRATING CODE REVIEW INTO PROJECT WORKFLOW

▸ Easy with tools like Github

▸ No excuse not to start using today

Page 163: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

EFFECTIVE CODE REVIEW

WHAT WE’VE COVERED

▸ Why

▸ Code quality

▸ What is code review

▸ Benefits

▸ Implementation

▸ Tips

▸ Integrating code review into project workflow

Page 164: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WRAP UP

Cost

DESIGN WRITING CODE

TEST RELEASE MAINTENANCE

FIND BUGS SOONER

Page 165: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WRAP UP

WHAT ARE DEFECTS?

Bugs

Evolvability [1, 2]

Page 166: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WRAP UP

SPREAD THE KNOWLEDGE

Page 167: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WRAP UP

MENTORING

Page 168: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WRAP UP

YOU’RE BEING WATCHED!

Page 169: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WRAP UP

YOU’RE BEING WATCHED!

[5]

Page 170: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WRAP UP

Page 171: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WRAP UP

SUMMARY: REVIEW CHECKLIST

▸ Security problems

▸ Correct tests

▸ Clean code

▸ Bugs

Page 172: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and
Page 173: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

WRAP UP

EVERYONE SHOULD CODE REVIEW

Page 174: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

EFFECTIVE CODE REVIEW REDUCES OVERALL COST OF SOFTWARE DEVELOPMENT

Page 175: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and
Page 176: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

FEEDBACK

https://joind.in/talk/ccc25 @daveliddament

Page 177: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

REFERENCES

REFERENCES

▸ [1] Mika V. Mantyla and Casper Lassenius “What Types of Defects Are Really Discovered in Code Reviews?” IEEE Transactions on Software Engineering

▸ [2] Harvey Siy, Lawrence Votta “Does The Modern Code Inspection Have Value?”

▸ [3] R.K. Bandi, V.K. Vaishnavi, and D.E. Turk, “Predicting Maintenance Performance Using Object-Orientated Design Complexity Metrics”

▸ [4] R.D. Banker, S.M. Datar, C.F. Kemerer, and D. Zweig, “Software Complexity and Maintenance Costs,”

▸ [5] https://www.bbc.co.uk/news/uk-37502136

▸ [6] https://smartbear.com/learn/code-review/best-practices-for-peer-code-review/

Page 178: Wi Twitter - Dave Liddament · 2020. 5. 28. · Integrating code review into project workflow. Dave Liddament Lamp Bristol ... We all make mistakes. If the mistakes are spotted and

CREDITS

IMAGE CREDITS

‣ © Can Stock Photo / kmitu

‣ © Kirsty Andrews

‣ © Jez Kent

‣ © Can Stock Photo / focalpoint

‣ © Can Stock Photo / sellingpix

‣ © Can Stock Photo / robwilson39

‣ © Can Stock Photo / lindwa

‣ © Can Stock Photo / piedmont_photo

‣ © Can Stock Photo / pressmaster

‣ © Can Stock Photo / marish