Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP)...

28
Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) [email protected] , [email protected] Twitter: @masohn @stefanlay

Transcript of Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP)...

Page 1: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Code Reviewas a Great Tool in the Agile Toolbox

Matthias Sohn,Stefan Lay (SAP)[email protected], [email protected]

Twitter: @masohn @stefanlay

Page 2: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Agenda

How we became agile

What we learned from Open Source

Why we embraced Code Review

How we scale up agile with Open Source processes  

Page 3: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Agile Feedback cycles

  

Source: http://en.wikipedia.org/wiki/Extreme_Programming

Page 4: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Agile Feedback cycles

  Pair Programming

Ralph and Karsten hacking on E4

Page 5: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Agile Feedback cycles

  Test Driven Development

Page 6: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Agile Feedback cycles

  Continuous Integration

Q: Who is who?

Page 7: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Agile Feedback cycles

Code Review?

Sometimes formal Code Review (Fagan style inspection)

Pair Programming is considered to be more agile• Higher bandwidth (Faster feedback)• Leads to faster integration than Code Review• “Individuals and interactions over processes and tools”

Page 8: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Agile Software Engineering

 Engineering practices are key

SAP trained its developers• > 4000 participants• 1 week training• 3 weeks coaching

Focus on• Scrum• Pair programming• Test Driven Development• Continuous Integration• Acceptance Tests

Page 9: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Code Review in Open Source

Maintainer Hierarchy / Contributors

Public peer review on mailing list

Committer / Contributor model

Public peer review • Patch in Bugzilla• Gerrit• Github

Page 10: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Code Review vs. Pair Programming

  

Page 11: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Code Review vs. Pair Programming

Code Review • leads to small, self-contained increments• ensures that ideas can be understood from code• leads to review discussions visible to everybody• leaves room to develop alternative solutions

Ideal complement to Pair Programming which is great to• explore unknown terrain• onboard new developer• combine complementary skills

Page 12: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Code Review is asynchronous

Can be done when there is timeThe whole team can review (also external reviewers)

Review takes time, but also leaves timeThis leads to parallel workflowGit perfectly supports this

Some aspects can be automated• Rule checking  • Build and test• Deployment to staging environment

All checks happen before submit

Page 13: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Code Review Best Practices

Small changes are much easier to review

A change should logically do one thing (not many)

No change shall break build or tests

Split big changes into series of digestible changes - These changes depend on each other- Last change should switch the new feature on

Commit message should explain Why - The What should be obvious from the code change

Page 14: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Code Review and Scrum

Successful code review required for a task to be finished

Many Done Criteria already checked during code review

Make review visible on Scrum Board

Reserve time for review

Everybody should review

Page 15: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Code Review and Scrum

Scrum Board

Story Bug Fix Review Story A Story B Story C …

Open

In Progress

In Review

Done

Page 16: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Code Review with Git and Gerrit

Gerrit is a Code Review system based on JGit http://code.google.com/p/gerrit/

Also serves as a Git server Adding access control and workflow

Used by • Android https://android-review.googlesource.com/• Eclipse https://git.eclipse.org/r/

• Google, QualComm, SAP, WikiMedia…

Page 17: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Code Review with Git and Gerrit

Page 18: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Code Review with Git and Gerrit

Gerrit usage at SAP started 2010

Projects: > 2.000Users: > 4.000Changes: > 300.000

Run by a small team of developers (us)

Training is important (> 400 developers)

Recently Git and Gerrit were approved as standard infrastructure

Page 19: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Scaling Agile with Open Source Processes

Agile processes work great for small teams

Collaboration between teams of a large project?

• High level planning of cross team topics still necessary

• Open Source like processes can replace detailed top-down planning

• Contribute to components owned by other teams• Review relevant changes of other teams• Scale up Pair Programming -> “Hackathons”

Page 20: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Contributions between teams

Find project information easily

Standardized infrastructure

Contributor Guide

Page 21: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Finding project info

Page 22: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Finding project info

Page 23: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Finding project info - Skalli

Page 24: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Standardized infrastructure

git clone <URL>

mvn clean install

Eclipse CBI: http://wiki.eclipse.org/CBI

Page 25: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Project specific

Standardized

Contributor Guide

Where to get the sourcesHow to setup the projectHow to buildReview processCommunication channelsCorrection Process

Coding conventionsHow to testReview rules…

Page 26: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Conclusion

Code Review brings additional value to agile teams

Git and Gerrit help a lot

Improves collaboration within and between teams

Standardization helps to scale

Page 27: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Questions & Answers

Page 28: Code Review as a Great Tool in the Agile Toolbox Matthias Sohn, Stefan Lay (SAP) Matthias.sohnn@sap.comMatthias.sohnn@sap.com, stefan.lay@sap.comstefan.lay@sap.com.

Agile Manifesto

Individuals and interactions over processes and tools

Working software over comprehensive documentation

Customer collaboration over contract negotiation

Responding to change over following a plan

In a complex and changing environment feedback is key!