what do code reviews at microsoft and in open source projects

82
What Do Code Reviews at Microsoft and in Open Source Projects Have in Common? Alberto Bacchelli Delft University of Technology The Netherlands

Upload: lamnhan

Post on 14-Feb-2017

217 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: What Do Code Reviews at Microsoft and in Open Source Projects

What Do Code Reviewsat Microsoft and in Open Source Projects Have in Common?

Alberto Bacchelli Delft University of Technology

The Netherlands

Page 2: What Do Code Reviews at Microsoft and in Open Source Projects
Page 3: What Do Code Reviews at Microsoft and in Open Source Projects
Page 4: What Do Code Reviews at Microsoft and in Open Source Projects
Page 5: What Do Code Reviews at Microsoft and in Open Source Projects

Modern code review

informal tool-based asynchronous

My code is better,after the review!!

Nice! He implemented all my suggestions..

Page 6: What Do Code Reviews at Microsoft and in Open Source Projects

Modern code review

informal tool-based asynchronous

My code is better,after the review!!

Nice! He implemented all my suggestions..

Page 8: What Do Code Reviews at Microsoft and in Open Source Projects

Code review tools: GitHub pull requests

Page 9: What Do Code Reviews at Microsoft and in Open Source Projects

Code review tools: Atlassian Crucible

Page 10: What Do Code Reviews at Microsoft and in Open Source Projects

Code review tools: Microsoft CodeFlow

1

2

3

4

5

6

Page 11: What Do Code Reviews at Microsoft and in Open Source Projects

Code review, an interactive online survey!

http://goo.gl/forms/hknZvi1YUo

http://sback.it/fosdem.html

Page 12: What Do Code Reviews at Microsoft and in Open Source Projects

Why research on modern code review?

Page 13: What Do Code Reviews at Microsoft and in Open Source Projects

Advances in Software Inspections M. E. Fagan

[IEEE TSE 1986]

Code “inspection is a method of static testing to verify that software meets its requirements.”

“It engages developers and others in a formal process [...] that usually detects more defects in the product than does machine testing.”

Code inspections

Page 14: What Do Code Reviews at Microsoft and in Open Source Projects

“It engages developers and others in a formal process [...] that usually detects more defects in the product than does machine testing.”

Code inspectionsCan you trust these results apply to

modern code review?

Page 15: What Do Code Reviews at Microsoft and in Open Source Projects

Dr. Christian Bird

Modern Code Review @ Microsoft

Page 16: What Do Code Reviews at Microsoft and in Open Source Projects

MICROSOFT AS SUBJECT

Modern Code Review @ Microsoft

Page 17: What Do Code Reviews at Microsoft and in Open Source Projects

Excel

XBox

SQL Server...

WindowsPhone

Modern Code Review @ Microsoft

Page 18: What Do Code Reviews at Microsoft and in Open Source Projects

1

2

3

4

5

The CodeFlow review tool

Used across all Microsoft product teamsExcel

SQL Server

XBox

by more than 70,000 developers, so far.

Page 19: What Do Code Reviews at Microsoft and in Open Source Projects

observations interviews

18 interviews with observations ~40 minutes long developers, testers different roles signed off at least 50 reviews

Page 20: What Do Code Reviews at Microsoft and in Open Source Projects
Page 21: What Do Code Reviews at Microsoft and in Open Source Projects

observations interviews

survey to 165 managers

Page 22: What Do Code Reviews at Microsoft and in Open Source Projects

Improve Dev. Process

Alternative Solutions

Code Improvement

Knowledge Transfer

Team Awareness

Avoid Build Breaks

Share Code Ownership

Track Rationale

Finding Defects

Team Assessment

List of motivations for doing code review

Page 23: What Do Code Reviews at Microsoft and in Open Source Projects

observations interviews

survey to 165 managers survey to 873 developers

Page 24: What Do Code Reviews at Microsoft and in Open Source Projects

0 200 400 600

1st reason 2nd reason 3rd reason

Why do Microsoft developers do code reviews?

finding defects

code improvements

alternative solutions

knowledge transfer

team awareness

improving dev process

share code ownership

Page 25: What Do Code Reviews at Microsoft and in Open Source Projects

0 200 400 600

1st reason 2nd reason 3rd reason

Why do Microsoft developers do code reviews?

finding defects

code improvements

alternative solutions

knowledge transfer

team awareness

improving dev process

share code ownership

“Finding defects is the main reason for doing code review.” 72 managers and 384 developers @ Microsoft

Page 26: What Do Code Reviews at Microsoft and in Open Source Projects

Let’s look at the survey’s answers!

Page 27: What Do Code Reviews at Microsoft and in Open Source Projects

What is the outcome of code review at Microsoft?

Page 28: What Do Code Reviews at Microsoft and in Open Source Projects

What is the outcome of code review at Microsoft?

Page 29: What Do Code Reviews at Microsoft and in Open Source Projects

Recorded code review comments

Page 30: What Do Code Reviews at Microsoft and in Open Source Projects

observations interviews

survey to 165 managers survey to 873 developers classification of570 review comments

Page 31: What Do Code Reviews at Microsoft and in Open Source Projects

Example stack of cards

Page 32: What Do Code Reviews at Microsoft and in Open Source Projects

Card sort almost completed

Page 33: What Do Code Reviews at Microsoft and in Open Source Projects

code improvementunderstanding

social communication defects

external impacttesting

review tool

0% 10% 20% 30%

% of comments

knowledge transfermisc

Card sort results

Page 34: What Do Code Reviews at Microsoft and in Open Source Projects

code improvementunderstanding

social communication defects

external impacttesting

review tool

0% 10% 20% 30%

% of comments

knowledge transfermisc

Card sort results

Page 35: What Do Code Reviews at Microsoft and in Open Source Projects

code improvementunderstanding

social communication defects

external impacttesting

review tool

0% 10% 20% 30%

% of comments

knowledge transfermisc

Card sort results

Page 36: What Do Code Reviews at Microsoft and in Open Source Projects

“what if they are all used?”

“any doubt about the precedence

here?”

“is it possible that this statement never match?”

“does it work if you put 0 here?”

“should this end date be current

date?”

“should be &&?”

defectsCard sort results

Page 37: What Do Code Reviews at Microsoft and in Open Source Projects

code improvementunderstanding

social communication defects

external impacttesting

review tool

0% 10% 20% 30%

% of comments

knowledge transfermisc

Card sort results

Page 38: What Do Code Reviews at Microsoft and in Open Source Projects

hot chocolate

Code review at Microsoft: Expectations vs. Reality

Page 39: What Do Code Reviews at Microsoft and in Open Source Projects

What is the outcome of code review in OSS?

Page 40: What Do Code Reviews at Microsoft and in Open Source Projects

Moritz Beller

Page 41: What Do Code Reviews at Microsoft and in Open Source Projects

What is the outcome of code review in OSS?

We manually analyzed 1,400 review-induced changes

Page 42: What Do Code Reviews at Microsoft and in Open Source Projects

What is the outcome of code review in OSS?

Page 43: What Do Code Reviews at Microsoft and in Open Source Projects

What is the outcome of code review in OSS?

Page 44: What Do Code Reviews at Microsoft and in Open Source Projects

What is the outcome of code review in OSS?

ConQAT

GROMACS 31%

22%

69%

78%

evolvability changes functional changes

Page 45: What Do Code Reviews at Microsoft and in Open Source Projects

What is the outcome of code review?

ConQAT

GROMACS

Microsoft 19%

31%

22%

81%

69%

78%

evolvability changes functional changes

Page 46: What Do Code Reviews at Microsoft and in Open Source Projects

What is the outcome of code review?

ConQAT

GROMACS

Microsoft

Industrial case

Students review 15%

23%

19%

31%

22%

85%

77%

81%

69%

78%

evolvability changes functional changes

Page 47: What Do Code Reviews at Microsoft and in Open Source Projects

What Do Code Reviewsat Microsoft and in Open Source Projects Have in Common?

Page 48: What Do Code Reviews at Microsoft and in Open Source Projects

What Do Code Reviewsat Microsoft and in Open Source Projects Have in Common?

The outcome

Page 49: What Do Code Reviews at Microsoft and in Open Source Projects
Page 50: What Do Code Reviews at Microsoft and in Open Source Projects

WHY?

Why do expectations not match reality?

Page 51: What Do Code Reviews at Microsoft and in Open Source Projects

… “[if] executed properly, [they] find bugs faster and more effectively than testing or other known debugging techniques”—but when done inefficiently they can quickly become unproductive.

— Jason Cohen, 2011

Code reviews

Page 52: What Do Code Reviews at Microsoft and in Open Source Projects

… “[if] executed properly, [they] find bugs faster and more effectively than testing or other known debugging techniques—but when done inefficiently they can quickly become unproductive. ”

— Jason Cohen, 2011

Code reviews

Page 53: What Do Code Reviews at Microsoft and in Open Source Projects

Code review is (still) a fully manual task

Page 54: What Do Code Reviews at Microsoft and in Open Source Projects

1

2

3

4

5

Tools only supports logistics of code review

Page 55: What Do Code Reviews at Microsoft and in Open Source Projects

Let’s look at the survey’s answers!

Page 56: What Do Code Reviews at Microsoft and in Open Source Projects

What are the challenges of code review at MSFT?

Page 57: What Do Code Reviews at Microsoft and in Open Source Projects

“understanding the code takes most of the reviewing time.”

What are the challenges of code review at MSFT?

Page 58: What Do Code Reviews at Microsoft and in Open Source Projects

Understanding needs, by outcome

Level of Understanding Needed

Responses

Avoid Build Breaks

Track Rationale

Team Awareness

Improve Dev Process

Code Improvement

Team Assessment

Knowledge Transfer

Share Code Ownership

Alternative Solutions

Finding Defects

500 0 500

None Low High Complete

finding defectsalternative solutions

code improvements

team awarenessimproving dev process

share code ownershipknowledge transfer

team assessment

track rationaleavoid build breaks

Page 59: What Do Code Reviews at Microsoft and in Open Source Projects

Understanding needs, by outcome

Level of Understanding Needed

Responses

Avoid Build Breaks

Track Rationale

Team Awareness

Improve Dev Process

Code Improvement

Team Assessment

Knowledge Transfer

Share Code Ownership

Alternative Solutions

Finding Defects

500 0 500

None Low High Complete

finding defectsalternative solutions

code improvements

team awarenessimproving dev process

share code ownershipknowledge transfer

team assessment

track rationaleavoid build breaks

Page 60: What Do Code Reviews at Microsoft and in Open Source Projects

Understanding needs, by outcome

Level of Understanding Needed

Responses

Avoid Build Breaks

Track Rationale

Team Awareness

Improve Dev Process

Code Improvement

Team Assessment

Knowledge Transfer

Share Code Ownership

Alternative Solutions

Finding Defects

500 0 500

None Low High Complete

finding defectsalternative solutions

code improvements

team awarenessimproving dev process

share code ownershipknowledge transfer

team assessment

track rationaleavoid build breaks

Page 61: What Do Code Reviews at Microsoft and in Open Source Projects

Effect of code ownership on reviews

Does it take longer to review files that you are not familiar with (or files that are new)?

“YES” 798 developers (91%)

Is there a difference in comments/feedback you receive when a reviewer is very familiar with or the owner of the files you changed in a code review?

“YES” 716 developers (82%)

Page 62: What Do Code Reviews at Microsoft and in Open Source Projects

Effect of code ownership on reviews

Is there a difference in comments/feedback you receive when a reviewer is very familiar with or the owner of the files you changed in a code review?

“Comments reflect their deeper understanding – more likely to find subtle defects, feedback is more conceptual (better ideas, approaches) instead of superficial (naming, mechanical style, etc.)”

“YES” 716 developers (82%)

Page 63: What Do Code Reviews at Microsoft and in Open Source Projects

Code review needs the right data and the right tools

codereview

Page 64: What Do Code Reviews at Microsoft and in Open Source Projects

FOCUS: GUEST EDITORS’ INTRODUCTIONFOCUS: GUEST EDITORS’ INTRODUCTION

IN THIS SPECIAL issue of IEEE Soft-ware, we invited submissions that re-flected the benefits (and drawbacks) of software analytics. The response was overwhelming. Software analytics is an area of explosive growth, and we had so many excellent submissions that we had to split this special issue into two volumes—you’ll see even more content in the September/Octo-ber issue. We divided the articles on conceptual grounds, so both volumes will feature equally excellent work.

To better frame these articles, we of-fer some definitions and historical per-spectives on software analytics. Specifi-cally, we describe where the field was, where it is, and where it might be going.

What Is Software Analytics?Thanks to the Internet and open source, there’s now so much data about software projects that it’s impossible to manually browse through it all:

• As of late 2012, our Web searches show that Mozilla Firefox had 800,000 bug reports, and platforms such as Sourceforge.net and GitHub hosted 324,000 and 11.2 mil-lion projects, respectively.

Software Analytics: So What?Tim Menzies, West Virginia University

Thomas Zimmermann, Microsoft Research

074 0 -74 5 9 /13 / $ 31. 0 0 © 2 013 I E E E JULY/AUGUST 2013 | IEEE SOFTWARE 31

… “is analytics on software data for managers and software engineers with the aim of empowering software development individuals and teams to gain and share insight from their data to make better decisions.”

— Menzies and Zimmermann, 2013

Software analytics

Page 65: What Do Code Reviews at Microsoft and in Open Source Projects

FOCUS: GUEST EDITORS’ INTRODUCTIONFOCUS: GUEST EDITORS’ INTRODUCTION

IN THIS SPECIAL issue of IEEE Soft-ware, we invited submissions that re-flected the benefits (and drawbacks) of software analytics. The response was overwhelming. Software analytics is an area of explosive growth, and we had so many excellent submissions that we had to split this special issue into two volumes—you’ll see even more content in the September/Octo-ber issue. We divided the articles on conceptual grounds, so both volumes will feature equally excellent work.

To better frame these articles, we of-fer some definitions and historical per-spectives on software analytics. Specifi-cally, we describe where the field was, where it is, and where it might be going.

What Is Software Analytics?Thanks to the Internet and open source, there’s now so much data about software projects that it’s impossible to manually browse through it all:

• As of late 2012, our Web searches show that Mozilla Firefox had 800,000 bug reports, and platforms such as Sourceforge.net and GitHub hosted 324,000 and 11.2 mil-lion projects, respectively.

Software Analytics: So What?Tim Menzies, West Virginia University

Thomas Zimmermann, Microsoft Research

074 0 -74 5 9 /13 / $ 31. 0 0 © 2 013 I E E E JULY/AUGUST 2013 | IEEE SOFTWARE 31

… “is analytics on software data for managers and software engineers with the aim of empowering software development individuals and teams to gain and share insight from their data to make better decisions.”

— Menzies and Zimmermann, 2013

Software analytics

Page 66: What Do Code Reviews at Microsoft and in Open Source Projects
Page 67: What Do Code Reviews at Microsoft and in Open Source Projects

Debugger

Versioning system

Issue tracking system

IDE Execution

Mailing system

Page 68: What Do Code Reviews at Microsoft and in Open Source Projects

software datasource code

issue tracking system

data mining and software analysis techniques

software engineering tasks helped

versioning system

clusteringpatternsclassification

neo

programming debugging maintenance testing…

Software analytics’ workflow

Page 69: What Do Code Reviews at Microsoft and in Open Source Projects

software datasource code

issue tracking system

data mining and software analysis techniques

software engineering tasks helped

versioning system

clusteringpatternsclassification

neo

code review

Software analytics for code reviews

review data

Page 70: What Do Code Reviews at Microsoft and in Open Source Projects

My research: Data-supported code reviewrecommenderfor reviewers

changeuntangler

automaticrisk detection

Page 71: What Do Code Reviews at Microsoft and in Open Source Projects

My research: Data-supported code reviewrecommenderfor reviewers

changeuntangler

automaticrisk detection

Page 72: What Do Code Reviews at Microsoft and in Open Source Projects

Who should review my code changes?recommenderfor reviewers

versioning system

changes toreview

code review data

neo

most appropriatereviewer #1

neo

most appropriatereviewer #2

neo

most appropriatereviewer #3

Page 73: What Do Code Reviews at Microsoft and in Open Source Projects

My research: Data-supported code reviewrecommenderfor reviewers

automaticrisk detection

changeuntangler

Page 74: What Do Code Reviews at Microsoft and in Open Source Projects

How should I split my code for easier review?change

untangler

versioning system

changes to review

self-containedchange

self-containedchange

Page 75: What Do Code Reviews at Microsoft and in Open Source Projects

My research: Data-supported code reviewrecommenderfor reviewers

changeuntangler

automaticrisk detection

Page 76: What Do Code Reviews at Microsoft and in Open Source Projects

Which changes should I review more carefully?

issue tracking system

versioning system

Octopull

automaticrisk detection

changes toreview

Page 77: What Do Code Reviews at Microsoft and in Open Source Projects

My research: Data-supported code reviewrecommenderfor reviewers

changeuntangler

automaticrisk detection

Page 78: What Do Code Reviews at Microsoft and in Open Source Projects

Add code review analytics support to GitHub

Page 79: What Do Code Reviews at Microsoft and in Open Source Projects

software datasource code

issue tracking system

data mining and software analysis techniques

software engineering tasks helped

versioning system

clusteringpatternsclassification

neo

code review

Software analytics for code reviews

review data

Page 80: What Do Code Reviews at Microsoft and in Open Source Projects
Page 81: What Do Code Reviews at Microsoft and in Open Source Projects

Would you like to work on these topics (with me)?

We have 3 fully funded 4-yearPhD (or postdoc) positions!

And we are always looking forgreat students to work

on fantastic Master theses!

Find me at the end of the talk, at [email protected] ,

or at @sback_

Page 82: What Do Code Reviews at Microsoft and in Open Source Projects