increasing code quality with code reviews (poetry version)

136
Increase Code Quality with Code Reviews David Stockton SkiPHP Conference 2014

Upload: david-stockton

Post on 10-May-2015

1.768 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Increasing code quality with code reviews (poetry version)

Increase Code Quality with Code Reviews

David Stockton SkiPHP Conference 2014

Page 2: Increasing code quality with code reviews (poetry version)

Increase Code Quality with Code Reviews

(Poetic Edition)

David Stockton SkiPHP Conference 2014

Page 3: Increasing code quality with code reviews (poetry version)

What is a Code Review?

Page 4: Increasing code quality with code reviews (poetry version)

A Code Review Is Making Your Code Better Than

It Would Be Without !

Page 5: Increasing code quality with code reviews (poetry version)

What is a code review?

A program looking at your

code

Page 6: Increasing code quality with code reviews (poetry version)

Skynet was started Code Review Reviewing Code

That was its own code

Page 7: Increasing code quality with code reviews (poetry version)

What is a code review?

Looking at someone

else’s code

Page 8: Increasing code quality with code reviews (poetry version)

I see what you did Your code sucks worse than ever

Undo that crap now!

Page 9: Increasing code quality with code reviews (poetry version)

What is a code review?

Someone else looking at your

code

Page 10: Increasing code quality with code reviews (poetry version)

I did that because I had a real good reason

I’ve forgotten it.

Page 11: Increasing code quality with code reviews (poetry version)

Common Ways to Do

Code Reviews

Page 12: Increasing code quality with code reviews (poetry version)

… And why those ways don’t work.

Page 13: Increasing code quality with code reviews (poetry version)

These are the things I’ve tried, I’ve tried These are the things

I’ve tried.

Page 14: Increasing code quality with code reviews (poetry version)

Ways to do Code Reviews

Email code or diffs

Page 15: Increasing code quality with code reviews (poetry version)

Code review email. Automatic filtering. Deleted. Unread.

Page 16: Increasing code quality with code reviews (poetry version)

Email Code Reviews

Create a diff, copy/paste code into an

email

Page 17: Increasing code quality with code reviews (poetry version)

This is what you do When you’ve too much time

on your hands And nothing really matters.

Anymore.

Mama Mia, Mama Mia, Mama Mia, let me go!

Page 18: Increasing code quality with code reviews (poetry version)

… and then?

Send to people you want to review your

code

Page 19: Increasing code quality with code reviews (poetry version)

Selecting my list My code review is sending

Sorry, reviewers.

Page 20: Increasing code quality with code reviews (poetry version)

Selecting my list My code review is sending

Sorry reviewers.

Page 21: Increasing code quality with code reviews (poetry version)

… and then?

They write back.

Page 22: Increasing code quality with code reviews (poetry version)

I got a reply! What did they think of my code?

I hate them, I think. :(

Page 23: Increasing code quality with code reviews (poetry version)

ERMAHGERD!

YER CODEZ SUCKZ!

Page 24: Increasing code quality with code reviews (poetry version)

My blood, sweat and tears Torn to ribbons in three words.

Your. Code. Sucks.

Page 25: Increasing code quality with code reviews (poetry version)

Reply back.

… Maybe.

Page 26: Increasing code quality with code reviews (poetry version)

I waited to hear. I should check my spam filter

Nope, it is empty.

Page 27: Increasing code quality with code reviews (poetry version)

Don’t you...

Response never comes.

Page 28: Increasing code quality with code reviews (poetry version)

There once was a man from Nantucket

Whose code reviews told developers to chuck it

They’d read it and weep And Crap code they’d keep

As they told the reviewer to go

Poem too long to fit, sorry...

Page 29: Increasing code quality with code reviews (poetry version)

… Forget about me

Or it’s ignored.

Page 30: Increasing code quality with code reviews (poetry version)

Expected response Got none for my code review Why should I bother?

Page 31: Increasing code quality with code reviews (poetry version)

You got me right in the feels

Text feedback taken in the most possible negative

way possible.

Page 32: Increasing code quality with code reviews (poetry version)

You said my code sucks Why do you h a t e me so much?

You are a huge jerk!

Page 33: Increasing code quality with code reviews (poetry version)

What a jerk!

From: Jake Developer!To: Byron Programmer!

Subject: Code Review for foo.php!!

Have you considered IOC for this? The current solution leads to a lack of extensibility which will probably

bite us later.!!

Also, two of the methods are missing doc comments and we need to put those

Page 34: Increasing code quality with code reviews (poetry version)

What a jerk!

From: Jake Developer!To: Byron Programmer!

Subject: Code Review for foo.php!

!

Have you considered IOC for this? The current solution

leads to a lack of

IOC? WTH does the International Olympic

Committee have to do with anything?

Page 35: Increasing code quality with code reviews (poetry version)

WTH does he know!

From: Jake Developer!To: Byron Programmer!

Subject: Code Review for foo.php!

!

Have you considered IOC for this? The current solution

leads to a lack of

Lack of extensibility. Why don’t you write the stupid

thing yourself?

Page 36: Increasing code quality with code reviews (poetry version)

D to the B!

From: Jake Developer!To: Byron Programmer!

Subject: Code Review for foo.php!

!

Have you considered IOC for this? The current solution

leads to a lack of

Bite Us? BITE ME!

Page 37: Increasing code quality with code reviews (poetry version)

...and the horse you rode in on!

From: Jake Developer!To: Byron Programmer!

Subject: Code Review for foo.php!

!

Have you considered IOC for this? The current solution

leads to a lack of

Missing DOC comments? Pick many nits lately?

Page 38: Increasing code quality with code reviews (poetry version)

From: Jake Developer!To: Byron Programmer!

Subject: Code Review for foo.php!

!

Have you considered IOC for this? The current solution

leads to a lack of

BALETED!

Picking my battles.

Page 39: Increasing code quality with code reviews (poetry version)
Page 40: Increasing code quality with code reviews (poetry version)

Ways to do code reviews

Evaluate Via Repo Diff

Page 41: Increasing code quality with code reviews (poetry version)

It’s just me… and me now

Usually done by one person

Page 42: Increasing code quality with code reviews (poetry version)

Lonely is the dev Reviewing Committed Code What is the point now?

Page 43: Increasing code quality with code reviews (poetry version)

Vacation? What’s vacation?

Requires Diligence

Page 44: Increasing code quality with code reviews (poetry version)

I checked in a LOT You didn’t say anything.

What is vay-cay-shun?

Page 45: Increasing code quality with code reviews (poetry version)

...and the bottle makes...

...and a small team

Page 46: Increasing code quality with code reviews (poetry version)

Didn’t we cover this?

Problems sent to dev via

email

Page 47: Increasing code quality with code reviews (poetry version)

Yes, yes we did.

See previous section for email

problems.

Page 48: Increasing code quality with code reviews (poetry version)

Yes, yes we did.

Second verse, same as the first.

Page 49: Increasing code quality with code reviews (poetry version)

There’s 24 hours in a day...

Large burden for single developer

Page 50: Increasing code quality with code reviews (poetry version)

Weight of the world is Is on my aching shoulders Must improve posture

Page 51: Increasing code quality with code reviews (poetry version)

It’s for your own good. I swear.

Developer usually very

senior to team

Page 52: Increasing code quality with code reviews (poetry version)

Why won’t everyone Recognize my super-brain!

I are the smartest!

Page 53: Increasing code quality with code reviews (poetry version)

Ways to do code reviews

Group Review in Conference

Room

Page 54: Increasing code quality with code reviews (poetry version)

Meetings are great tools To help everyone do

Just about nothing.

Page 55: Increasing code quality with code reviews (poetry version)

Movie night!

Gather developers

around a TV

Page 56: Increasing code quality with code reviews (poetry version)

I checked the reviews Rotten Tomatoes Gives It Code Review: Zero Stars

Worst plot evAr!

Page 57: Increasing code quality with code reviews (poetry version)

Time… is (not) on my side…

Takes up a lot of time

Page 58: Increasing code quality with code reviews (poetry version)

Meetings are great tools To help everyone do

Just about nothing.

Page 59: Increasing code quality with code reviews (poetry version)

People who enjoy meetings...

Yet another meeting.

Page 60: Increasing code quality with code reviews (poetry version)

…should not be in charge…

Developer can feel attacked.

Page 61: Increasing code quality with code reviews (poetry version)

Why’s everyone Always picking on me? Cuz I code like a chump And I don’t test anything

Page 62: Increasing code quality with code reviews (poetry version)

… of anything.

Needs a moderator

Page 63: Increasing code quality with code reviews (poetry version)

Just like herding cats So too is the job of the

Moderator guy.

Page 64: Increasing code quality with code reviews (poetry version)

After meetings, second favorite thing

Needs a note taker

Page 65: Increasing code quality with code reviews (poetry version)

Take note of this Said the young developer

Your code… Is bogus.

Page 66: Increasing code quality with code reviews (poetry version)

Why bother one person…

Often takes up the whole

team.

Page 67: Increasing code quality with code reviews (poetry version)

I was going to work But a code review says “No”

You will do no work.

Page 68: Increasing code quality with code reviews (poetry version)

…when you can bother everyone.

Not possible for all the changes.

Page 69: Increasing code quality with code reviews (poetry version)

Sometimes code is long A meeting will last too long Just let it go through?

Page 70: Increasing code quality with code reviews (poetry version)

Ways to do code reviews

Over-shoulder code review

Page 71: Increasing code quality with code reviews (poetry version)

I want to review But I cannot see your code.

Your hair is too big.

Page 72: Increasing code quality with code reviews (poetry version)

Developer in control

Page 73: Increasing code quality with code reviews (poetry version)

Please ignore that mess If you say nothing

Then it’s fine to go to prod.

Page 74: Increasing code quality with code reviews (poetry version)

Stop this review, I want to get off!

Reviewer Along for the

Ride

Page 75: Increasing code quality with code reviews (poetry version)

You asked me for help Where did the code go poorly?

You will not show me.

Page 76: Increasing code quality with code reviews (poetry version)

I hope that’s what you wanted to see

Developer leads reviewer through code

Page 77: Increasing code quality with code reviews (poetry version)

What I saw looked good…

Not much chance to

really review

Page 78: Increasing code quality with code reviews (poetry version)

I saw some good stuff The stuff you let me look at The rest must be fine.

Page 79: Increasing code quality with code reviews (poetry version)

Hey… Hey… HEY!

Interrupt the reviewer

Page 80: Increasing code quality with code reviews (poetry version)

Stop this code review I want to get off and look

What has changed in here?

Page 81: Increasing code quality with code reviews (poetry version)

We get to do that all again?

More than one reviewer

Page 82: Increasing code quality with code reviews (poetry version)

Oh, joy, what fun! And Now I get to do that all Back into the breach.

Page 83: Increasing code quality with code reviews (poetry version)

“I have way too much time” - No one

More time lost for developer

Page 84: Increasing code quality with code reviews (poetry version)

As I grow older and wiser I try to avoid

wasting time. - Bye. !

- SarcasmSociety

Page 85: Increasing code quality with code reviews (poetry version)

Ways to do code reviews

Pull Request Code Review

Page 86: Increasing code quality with code reviews (poetry version)

Not totally “teh suck”

One of the better options

Page 87: Increasing code quality with code reviews (poetry version)

Top-bottom diffs are Not as easy to read as Side to side code is.

Page 88: Increasing code quality with code reviews (poetry version)

</poetry>

Page 89: Increasing code quality with code reviews (poetry version)

Why you no take my code?

May require a pull-request

process

Page 90: Increasing code quality with code reviews (poetry version)

DVCS FTW!

Works great with git and mercurial

Page 91: Increasing code quality with code reviews (poetry version)

Sucky Version Numbers Crappy Version System

Less so with SVN or CVS

Page 92: Increasing code quality with code reviews (poetry version)

This is my rifle, this is a wrench...

Code review tools vary a

LOT

Page 93: Increasing code quality with code reviews (poetry version)

Ways to do code reviews

What does work?

Page 94: Increasing code quality with code reviews (poetry version)

Use the right tool for the job

Formal Code Review With

Software

Page 95: Increasing code quality with code reviews (poetry version)

Don’t hammer screws with a saw

Specifically Code Review

Software

Page 96: Increasing code quality with code reviews (poetry version)

It’s like they made it to do this.

Designed for Easy Review of Changes

Page 97: Increasing code quality with code reviews (poetry version)

Do it on your own time.

Reviews Don’t Interrupt

Development

Page 98: Increasing code quality with code reviews (poetry version)

If only I could write what I thought.

Comments on lines /groups

of lines

Page 99: Increasing code quality with code reviews (poetry version)

Comment all the things!

Comments on overall

changes

Page 100: Increasing code quality with code reviews (poetry version)

What are you going to say about it?

Allows for replies to comments

Page 101: Increasing code quality with code reviews (poetry version)

What about the code as a whole?

Overall Review Status

Page 102: Increasing code quality with code reviews (poetry version)

Stuff that has to be fixed

Issues

Page 103: Increasing code quality with code reviews (poetry version)

It’s all good

“Ship It”

Page 104: Increasing code quality with code reviews (poetry version)

Did you make the changes?

Allows for Updating Diffs

Page 105: Increasing code quality with code reviews (poetry version)

Code based on someone else’s code.

Diffs with Parent Diffs

Page 106: Increasing code quality with code reviews (poetry version)

Git, Hg, SVN, etc

Allow for Multiple VCS

Page 107: Increasing code quality with code reviews (poetry version)

Why don’t all things have APIs?

API to integrate into

process

Page 108: Increasing code quality with code reviews (poetry version)

How to Implement Formal Code Review

Installation / Hosted

Page 109: Increasing code quality with code reviews (poetry version)

How to Implement Formal Code Review

Get buy-in by devs and

management

Page 110: Increasing code quality with code reviews (poetry version)

How to Implement Formal Code Review

Decide how to integrate into

process.

Page 111: Increasing code quality with code reviews (poetry version)

How to Implement Formal Code Review

How many reviews?

Page 112: Increasing code quality with code reviews (poetry version)

How to Implement Formal Code Review

How many ship its?

Page 113: Increasing code quality with code reviews (poetry version)

How to Implement Formal Code Review

Other requirements or restrictions

Page 114: Increasing code quality with code reviews (poetry version)

How to Implement Formal Code Review

Timeframe to complete

review

Page 115: Increasing code quality with code reviews (poetry version)

How to Implement Formal Code Review

Timeframe for responses

Page 116: Increasing code quality with code reviews (poetry version)

Code of Conduct for Reviews

No personal attacks

Page 117: Increasing code quality with code reviews (poetry version)

Code of Conduct for Reviews

Really. No personal

attacks

Page 118: Increasing code quality with code reviews (poetry version)

Code of Conduct for Reviews

Constructive criticism

Page 119: Increasing code quality with code reviews (poetry version)

Code of Conduct for Reviews

Constructive criticism only.

Page 120: Increasing code quality with code reviews (poetry version)

How to Implement Formal Code Review

No long ongoing

conversations

Page 121: Increasing code quality with code reviews (poetry version)

How to Implement Formal Code Review

Move those to in-person, video, etc

Page 122: Increasing code quality with code reviews (poetry version)

How to Implement Formal Code Review

Keep the review about

the code

Page 123: Increasing code quality with code reviews (poetry version)

How to Implement Formal Code Review

What can be considered “issues”?

Page 124: Increasing code quality with code reviews (poetry version)

Benefits of Formal Code

Review

Page 125: Increasing code quality with code reviews (poetry version)

Benefits of Formal Code Review

Better Code

Page 126: Increasing code quality with code reviews (poetry version)

Benefits of Formal Code Review

Bugs caught before launch or QA testing

Page 127: Increasing code quality with code reviews (poetry version)

Benefits of Formal Code Review

Learning Opportunity for All Devs

Page 128: Increasing code quality with code reviews (poetry version)

Benefits of Formal Code Review

More eyes leads to better

code

Page 129: Increasing code quality with code reviews (poetry version)

Software

• Review Board • Atlassian Crucible • Code Collaborator • Phabricator • Kiln • etc

Page 130: Increasing code quality with code reviews (poetry version)
Page 131: Increasing code quality with code reviews (poetry version)
Page 132: Increasing code quality with code reviews (poetry version)
Page 133: Increasing code quality with code reviews (poetry version)
Page 134: Increasing code quality with code reviews (poetry version)
Page 135: Increasing code quality with code reviews (poetry version)
Page 136: Increasing code quality with code reviews (poetry version)

Please rate this talk

https://joind.in/10448