Effective Code Review

28
Effective Code Review Jane Prusakova @jprusakova

Transcript of Effective Code Review

EffectiveCode Review

Jane Prusakova@jprusakova

Judge a coder by the code?

Author

Reviewer

Code

Cooperation, not competition

Attention is respect

Everyone is a reviewer

Judge a coder by the code?

Cooperation, not competition

Attention is respect

Everyone is a reviewer

Author

Reviewer

Code

Size matters• Consistent criteria

• Maintain focus

• Be agile• Limit scope• Limit time

Bucket listVisual layout

Naming

Architecture

Test coverage

• Is it

readable*?• Is it good

maintainable code? • Does it do

what it appears to do?

What is readable code?Defined by technology community

Common knowledge

Expected tenure

Popular tools

Skip

Explanations what the code does

Checks by automated tools

Reasons why this code is bad

Arguments about preferences*

Code review is NOTA substitute for the QA

A check on automated tools results

A discussion on formatting, tools, or patterns

All code must be perfect?

YesNoIt depends

Goals of code review Immediate benefit

Medium to longer-term improvements

Building technical community

BugsUnintended

behavior

Bad Code

Bugs coming soon

Erratic codeHard to

understand

Common Vision

-ilitiesDependenciesPoor scalability

Good CodeWorthy of a compliment

Code review is not a meeting

Preparation Conversation Follow up0

0.5

1

1.5

2

2.5

3

3.5

4

4.5

Author Reviewer(s)

Code review is not a meeting

Preparation Conversation Follow up0

0.5

1

1.5

2

2.5

3

3.5

4

4.5

Author Reviewer(s)

Author

Verify test coverageRun code quality tools

Fix problems

Reviewer

Run testsRead the codeRead the tests

Be prepared

Readability

Short code blocks

Minimize nestedness

Minimize comments

Mind abstraction levels

Show logic

One decision per code block

Show main line of reasoning

D.R.Y.

Test every scenario exactly once

NamingMake sense

Accepted terminology

Abbreviations

As short as possible but not any shorter

oviAnioviparousAnimal

Chicken!

Code quality

Architecture

GRASP

S.O.L.I.D.

GoF patterns

D.R.Y.

REST SOA

Architecture

Code reflects understanding

Architecture technical details

Standard practices

Consistent patterns

Minimize reliance on order

TestsAll scenarios covered

No repetitive tests

Prefer stubs to mocks

Outcome

Learning

Recommendations

Try-it-out

Follow upReview the recommendations

Make changes

Apply learning

Prepare for the next code review

Technical Quality

Takes time

Takes a community

Takes iterations

Write code

Prepare for code review

Code review

Follow up

BugsUnintended

behavior

Bad Code

Bugs coming soon

Erratic codeHard to

understand

Common Vision

-ilitiesDependenciesPoor scalability

Good CodeWorthy of a compliment

GOOD CODE

SHARED UNDERSTANDING

IMPROVING

Code review is like pants. If you work alone, pants are optional. But if you are part of a team, make sure you have pants on.

EffectiveCode Review

Jane Prusakova@jprusakova