SlideShare una empresa de Scribd logo
1 de 90
Descargar para leer sin conexión
another pair of eyes:
reviewing code well
adam dangoor
twitter: adamdangoor
github: adamtheturtle
why?
•
•
•
why?
• great reviews have helped
•
•
“Your	code	sucks,	and	I	hate	you”	
-	biog	post	by	jml
why?
• great reviews have helped
• bad reviews have harmed
•
•
why?
• great reviews have helped
• bad reviews have harmed
• hardly talked about
•
why?
• great reviews have helped
• bad reviews have harmed
• hardly talked about
•
why?
• great reviews have helped
• bad reviews have harmed
• hardly talked about
• little to no training
the plan
• what code review is
• how I review code
• some common pitfalls
• tools which can help
• becoming a better programmer
what is code review?
•
•
•
what is code review?
• catch bugs early - prevention is cheaper than cure
•
•
what is code review?
• catch bugs early - prevention is cheaper than cure
•
•
what is code review?
• catch bugs early - prevention is cheaper than cure
• find other defects early
what is code review?
• catch bugs early - prevention is cheaper than cure
• find other defects early
• share knowledge
what is code review?
• catch bugs early - prevention is cheaper than cure
• find other defects early
• share knowledge
the project’s other goals
setting the scene
setting the scene:
the issue
setting the scene:
the branch
eleanor~>	git	checkout	-b	show-employer-2866
setting the scene:
the code
def	get_user_profile(user):	
			“””	
			Get	a	dict	representing	a	user’s	profile.	
			“””	
			user_profile	=	{}	
			user_profile['Age']	=	user.get_age(unit='years')	
			user_profile['Twitter	Handle']	=	user.twitter_handle	
			return	user_profile
setting the scene:
the code
eleanor~> git diff
diff --git a/api/profiles.py b/api/profiles.py
index 776e5e0..7fff02c 100644
--- a/api/profiles.py
+++ b/api/profiles.py
@@ -2,7 +2,7 @@
user_profile['Age'] = user.get_age(unit='years')
user_profile['Twitter Handle'] = user.twitter_handle
+ user_profile['Latest employer'] = 
+ user.get_employers()[0].name
return user_profile
setting the scene:
the manual test
do we need a review?
do we need a review?
(yes)
do we need a review
for trivial changes?
do we need a review
for urgent work?
stage fright
who should do the review?
•
•
who should do the review?
• someone with authorisation (technical or social)
•
•
who should do the review?
• someone with authorisation (technical or social)
• not an author
•
who should do the review?
• someone with authorisation (technical or social)
• not an author
• someone who has written nearby code
•
who should do the review?
• someone with authorisation (technical or social)
• not an author
• someone who has written nearby code
• or someone who has reviewed nearby code
but what about
knowledge sharing?
code review as a new
starter
code review as a new
starter
how i do a review
read the spec
check ci
is the spec
implemented?
have we interpreted
the spec the same?
does the implementation
look functionally correct?
has existing functionality
been broken?
is it going to be easy to
maintain?
is it going to be easy to
maintain?
is everything
documented?
learning
initiating a discussion
concluding a review
• Great, this looks good to me, I’ll merge it
• Please make the requested changes and then merge
• Please make the requested changes and then
resubmit
• I’m not qualified to know whether this is a suitable
change, let’s find someone else to have a look
getting better
ask for feedback
reviewing eleanor’s
change
user_profile['Age'] = user.get_age(unit='years')
user_profile['Twitter Handle'] = user.twitter_handle
+ user_profile['Latest employer'] = 
+ user.get_employers()[0].name
return user_profile
reviewing eleanor’s
change
eleanor’s next steps
eleanor’s next steps
eleanor~> ag --ignore-case "latest employer”
~/Documents/bilbao_inc/api/profile.py
user_profile['Latest employer'] = 
~/Documents/bilbao_inc/api/details_email.py
"Latest employer: {latest_employer}".format(
being nice to people
always say one nice
thing[1]
being	nice	to	people
[1] Divmod via jml
address the patch, not
the person
being	nice	to	people
what else could be
better?
what else could be
better?
clear	next	steps
what else could be
better?
the	review	stopped	too	
soon
user_profile['Twitter Handle'] = user.twitter_handle
+ user_profile['Latest employer'] = 
+ user.get_employers()[0].name
return user_profile
what else could be
better?
when	to	stop
the next round
eleanor~> git diff
diff --git a/api/profiles.py b/api/profiles.py
index 776e5e0..7fff02c 100644
--- a/api/profiles.py
+++ b/api/profiles.py
@@ -2,7 +2,7 @@
user_profile['Age'] = user.get_age(unit='years')
user_profile['Twitter Handle'] = user.twitter_handle
+ try:
+ user_profile['Latest employer'] = 
+ user.get_employers()[0].name
+ except:
+ user_profile['Latest employer'] = 
+ “This user does not have any employment
history in the system yet.”
return user_profile
the next round
• performance issue
•
•
the next round
• performance issue
• pep 8 violation
•
the next round
• performance issue
• pep 8 violation
• properties vs getters
priorities and context
style guide vs style
rules
automate the boring
stuff
flake8
automate the boring
stuff
coverage.py	&	coveralls
requires.io
automate the boring
stuff
landscape.io
automate the boring
stuff
docs	tools
trade-offs
ignoring suggestions
#	pylint	thinks	that	this	is	too	long	for	a	function	name.	
#	Ignore	that	error.	
def	update_current_search_index():	#	pylint:	disable-msg=C0103
configuring suggestions
[flake8]	
ignore	=	D203	
exclude	=	.git,__pycache__,docs/source/conf.py,old,build,dist	
max-complexity	=	10
github integration
reviewable.io
unrelated changes
unrelated changes
reviewable changes
reviewable changes are
short
Magnetic platform guide: ~200 line changes max
Twisted: ~200 line changes max
reviewable changes
include one logical unit of
change
writing reviewable
code
silicon valley comma
silicon valley comma
landmarks = [
guggenheim,
fine_arts_museum,
basilica,
+ euskalduna,
]
vs
landmarks = [
guggenheim,
fine_arts_museum,
- basilica
+ basilica,
+ euskalduna,
]
semantic linefeeds
by brandon rhodes
adam~> git diff
diff --git a/api/example.txt b/api/example.txt
index 776e5e0..7fff02c 100644
--- a/api/example.txt
+++ b/api/example.txt
@@ -2,7 +2,7 @@
- The beauteous scheme is that now,
+ The beauty of this scheme is that now,
if you change your mind
about what a paragraph should look like,
tips vs requirements
learning by reviewing
cheers
adam dangoor
twitter: adamdangoor
github: adamtheturtle
stuffadammakes.com

Más contenido relacionado

La actualidad más candente

Drupalcamp Simpletest
Drupalcamp SimpletestDrupalcamp Simpletest
Drupalcamp Simpletest
lyricnz
 
Test automation expert days
Test automation   expert daysTest automation   expert days
Test automation expert days
Oren Rubin
 
Auditing Drupal Sites
Auditing Drupal SitesAuditing Drupal Sites
Auditing Drupal Sites
Exove
 

La actualidad más candente (20)

Working Software Over Comprehensive Documentation
Working Software Over Comprehensive DocumentationWorking Software Over Comprehensive Documentation
Working Software Over Comprehensive Documentation
 
Enhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order componentEnhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order component
 
Getting By Without "QA"
Getting By Without "QA"Getting By Without "QA"
Getting By Without "QA"
 
Selenium and Cucumber Selenium Conf 2011
Selenium and Cucumber Selenium Conf 2011Selenium and Cucumber Selenium Conf 2011
Selenium and Cucumber Selenium Conf 2011
 
Use React Patterns to Build Large Scalable App
Use React Patterns to Build Large Scalable App Use React Patterns to Build Large Scalable App
Use React Patterns to Build Large Scalable App
 
Points.com fisheye crucible code reviews 2011
Points.com fisheye crucible code reviews 2011Points.com fisheye crucible code reviews 2011
Points.com fisheye crucible code reviews 2011
 
Front-end Automated Testing
Front-end Automated TestingFront-end Automated Testing
Front-end Automated Testing
 
Drupalcamp Simpletest
Drupalcamp SimpletestDrupalcamp Simpletest
Drupalcamp Simpletest
 
Cucumber
CucumberCucumber
Cucumber
 
Testing in Vue.js
Testing in Vue.jsTesting in Vue.js
Testing in Vue.js
 
Meet my CI
Meet my CIMeet my CI
Meet my CI
 
Selenium testing IDE 101
Selenium testing IDE 101Selenium testing IDE 101
Selenium testing IDE 101
 
Automate testing with behat, selenium, phantom js and nightwatch.js (5)
Automate testing with behat, selenium, phantom js and nightwatch.js (5)Automate testing with behat, selenium, phantom js and nightwatch.js (5)
Automate testing with behat, selenium, phantom js and nightwatch.js (5)
 
How to Build and Maintain Quality Drupal Sites with Automated Testing
How to Build and Maintain Quality Drupal Sites with Automated TestingHow to Build and Maintain Quality Drupal Sites with Automated Testing
How to Build and Maintain Quality Drupal Sites with Automated Testing
 
軟體測試是在測試什麼?
軟體測試是在測試什麼?軟體測試是在測試什麼?
軟體測試是在測試什麼?
 
Test automation with cucumber jvm
Test automation with cucumber jvmTest automation with cucumber jvm
Test automation with cucumber jvm
 
Test automation expert days
Test automation   expert daysTest automation   expert days
Test automation expert days
 
Crucible
CrucibleCrucible
Crucible
 
Web Cache Deception Attack
Web Cache Deception AttackWeb Cache Deception Attack
Web Cache Deception Attack
 
Auditing Drupal Sites
Auditing Drupal SitesAuditing Drupal Sites
Auditing Drupal Sites
 

Similar a Another pair of eyes

Behaviour drivendevelopment
Behaviour drivendevelopmentBehaviour drivendevelopment
Behaviour drivendevelopment
Young Alista
 
Behaviour driven development
Behaviour driven developmentBehaviour driven development
Behaviour driven development
Tony Nguyen
 
Behaviour driven development
Behaviour driven developmentBehaviour driven development
Behaviour driven development
James Wong
 
Behaviour drivendevelopment
Behaviour drivendevelopmentBehaviour drivendevelopment
Behaviour drivendevelopment
Luis Goldster
 
Behaviour driven development
Behaviour driven developmentBehaviour driven development
Behaviour driven development
Fraboni Ec
 
Behaviour driven development
Behaviour driven developmentBehaviour driven development
Behaviour driven development
Harry Potter
 
The business case for contributing code
The business case for contributing codeThe business case for contributing code
The business case for contributing code
Zivtech, LLC
 
AGILE DEVELOPMENT
AGILE DEVELOPMENTAGILE DEVELOPMENT
AGILE DEVELOPMENT
we20
 
How To Do Kick-Ass Software Development, by Sven Peters
How To Do Kick-Ass Software Development, by Sven PetersHow To Do Kick-Ass Software Development, by Sven Peters
How To Do Kick-Ass Software Development, by Sven Peters
ZeroTurnaround
 

Similar a Another pair of eyes (20)

What designers can learn from (code) review
What designers can learn from (code) reviewWhat designers can learn from (code) review
What designers can learn from (code) review
 
You cant be agile if your code sucks
You cant be agile if your code sucksYou cant be agile if your code sucks
You cant be agile if your code sucks
 
Code Review: How and When
Code Review: How and WhenCode Review: How and When
Code Review: How and When
 
CI doesn’t start with Jenkins
CI doesn’t start with JenkinsCI doesn’t start with Jenkins
CI doesn’t start with Jenkins
 
Achieving Technical Excellence in Your Software Teams - from Devternity
Achieving Technical Excellence in Your Software Teams - from Devternity Achieving Technical Excellence in Your Software Teams - from Devternity
Achieving Technical Excellence in Your Software Teams - from Devternity
 
Behaviour drivendevelopment
Behaviour drivendevelopmentBehaviour drivendevelopment
Behaviour drivendevelopment
 
Behaviour driven development
Behaviour driven developmentBehaviour driven development
Behaviour driven development
 
Behaviour driven development
Behaviour driven developmentBehaviour driven development
Behaviour driven development
 
Behaviour drivendevelopment
Behaviour drivendevelopmentBehaviour drivendevelopment
Behaviour drivendevelopment
 
Behaviour drivendevelopment
Behaviour drivendevelopmentBehaviour drivendevelopment
Behaviour drivendevelopment
 
Behaviour driven development
Behaviour driven developmentBehaviour driven development
Behaviour driven development
 
Behaviour driven development
Behaviour driven developmentBehaviour driven development
Behaviour driven development
 
The business case for contributing code
The business case for contributing codeThe business case for contributing code
The business case for contributing code
 
Style guide driven development
Style guide driven developmentStyle guide driven development
Style guide driven development
 
True Git
True Git True Git
True Git
 
AGILE DEVELOPMENT
AGILE DEVELOPMENTAGILE DEVELOPMENT
AGILE DEVELOPMENT
 
How To Do Kick-Ass Software Development, by Sven Peters
How To Do Kick-Ass Software Development, by Sven PetersHow To Do Kick-Ass Software Development, by Sven Peters
How To Do Kick-Ass Software Development, by Sven Peters
 
Code Review: How and When
Code Review: How and WhenCode Review: How and When
Code Review: How and When
 
Code Review
Code ReviewCode Review
Code Review
 
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019Joe Cisar - Everything I Know About TDD - Agile Midwest 2019
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019
 

Último

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 

Último (20)

WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 

Another pair of eyes