SlideShare une entreprise Scribd logo
1  sur  33
Télécharger pour lire hors ligne
Code Reviews in Python
César Cárdenas Desales
Zürich Python User Group, June 2016
2
About me
● Software Architect at Webrepublic AG
● Python user since v.2.0
● Co-organizer of the Swiss Python Summit
¿What are Code Reviews?
3
Systematic examination of computer source code…
- Wikipedia
Benefits
4
● Timeless
● Spread knowledge
● The Ego Factor
● Increase quality of software
Timeless
5
● Being here for a while (Fagan, 1976)
● Not going away any time soon
● Technology agnostic
● Not a fad
Timeless
6
● Fad?
○ Machine learning?
○ SOA?
○ OOP?
○ Client server architecture?
○ Big data?
○ Cloud computing?
○ SVN
● Fad
○ Aspect Oriented Programming
○ Java applets
○ Visual Programming
○ Enterprise JavaBeans
○ CGI (Web)
○ Webmasters
Spread knowledge
7
● Beginners learn from the experts’ code
● The experienced get to know other modules or
systems
● Increases “Bus Factor”
The Ego Factor
8
● No “quick and dirty” fixes
● Reputation at stake on each commit
Increase quality of software
9
● Reviewed solutions tend to be better
● Defects are found and fixed early
Source: IBM Systems Sciences Institute
Assign Reviewers
10
● Everyone participates
● Works well with couples
● ¿How long?
~1 sprint or week
Assign Reviewers
11
● 50%
● 100%
12
Code Review with Github
Implementation
Pull
Request
Discusion
Preparation Revision Closure
Revision
Merge
Branch
12
Commit
Preparation
13
1. Branch
2. Commit
3. Pull Request
Revision
14
4. First response
5. Review code
6. Written comments /
discussion
Closure
15
6. Implement changes under agreement
7. Merge
1616
Rule #1
It’s not personal
Basic Rules
17
● Respond (ACK) and solve in a timely manner
● Not too little, not too much
(400 loc. max.)
● Ask before overwriting somebody’s code
● Use checklists
Code conventions and style guides
Criteria - Pythonic code
18
Pycodestyle / Flake8 / Pylint
Code conventions and style guides
Criteria - Pythonic code
19
Pythonic code
pycodestyle / Flake8 / Pylint
Code conventions and style guides
Criteria - Pythonic code
20
Pythonic code
pycodestyle / Flake8 / Pylint
Criteria - Pythonic code
21
Zen of Python
>>> import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
...
Pythonic code
Criteria - Pythonic code
22
Pythonic code
Criteria - Pythonic code
23
Pythonic code
Criteria - Pythonic code
24
Pythonic code
Criteria - Pythonic code
25
TODO/FIXME: Name and shame, ticket number, date
Criteria
26
Cyclomatic complexity
Criteria
27
Input data validation
Updated comments & docstrings
Dead or commented out code
Criteria
28
exec() / eval()
Passwords or tokens in repository
Automated unit tests: unittest / pytest / nose / coverage
Criteria
29
Efficient algorithms
Edge cases / off by 1 errors
Duplicated code / copy & paste
Criteria
30
Antipatterns
● God class/function
● Lasagna code
● Magic numbers
● Reinventing the wheel (!)
Criteria
31
Antipatterns
● Circular dependencies
(relative imports)
● Premature optimization -> YAGNI
● Boat Anchor
● Object Orgy
Criteria
32
Is there a better solution?
Is it scalable?
33
Let’s make it happen.
Thanks!
cesar.desales@webrepublic.com
@ccdesales

Contenu connexe

Tendances

Can PL/SQL be Clean? (2013)
Can PL/SQL be Clean? (2013)Can PL/SQL be Clean? (2013)
Can PL/SQL be Clean? (2013)
Peter Kofler
 
Teldap4 getty multilingual vocab workshop2010
Teldap4 getty multilingual vocab workshop2010Teldap4 getty multilingual vocab workshop2010
Teldap4 getty multilingual vocab workshop2010
AAT Taiwan
 

Tendances (20)

Can PL/SQL be Clean? (2013)
Can PL/SQL be Clean? (2013)Can PL/SQL be Clean? (2013)
Can PL/SQL be Clean? (2013)
 
Improving Automated Tests with Fluent Assertions
Improving Automated Tests with Fluent Assertions Improving Automated Tests with Fluent Assertions
Improving Automated Tests with Fluent Assertions
 
Coding Dojo: Baby Steps Push Challenge (2021)
Coding Dojo: Baby Steps Push Challenge (2021)Coding Dojo: Baby Steps Push Challenge (2021)
Coding Dojo: Baby Steps Push Challenge (2021)
 
OmegaT "Team Project" feature: a case study
OmegaT "Team Project" feature: a case studyOmegaT "Team Project" feature: a case study
OmegaT "Team Project" feature: a case study
 
Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2
 
Data Generation with PROSPECT: a Probability Specification Tool
Data Generation with PROSPECT: a Probability Specification ToolData Generation with PROSPECT: a Probability Specification Tool
Data Generation with PROSPECT: a Probability Specification Tool
 
Practical pointers for better code review
Practical pointers for better code reviewPractical pointers for better code review
Practical pointers for better code review
 
4gl code parser
4gl code parser 4gl code parser
4gl code parser
 
Tdd presentation
Tdd presentationTdd presentation
Tdd presentation
 
Globalization autdi for Fedora Atomic
Globalization autdi for Fedora AtomicGlobalization autdi for Fedora Atomic
Globalization autdi for Fedora Atomic
 
Challenges operating and scaling GrapheneDB by Francisco Fernandez
Challenges operating and scaling GrapheneDB by Francisco Fernandez Challenges operating and scaling GrapheneDB by Francisco Fernandez
Challenges operating and scaling GrapheneDB by Francisco Fernandez
 
Importance of the quality of code
Importance of the quality of codeImportance of the quality of code
Importance of the quality of code
 
L7 firewall API for Neutron-FWaaS
L7 firewall API for Neutron-FWaaSL7 firewall API for Neutron-FWaaS
L7 firewall API for Neutron-FWaaS
 
Class 4 IPO and Intro to Ruby
Class 4 IPO and Intro to RubyClass 4 IPO and Intro to Ruby
Class 4 IPO and Intro to Ruby
 
Python lecture 01
Python lecture 01Python lecture 01
Python lecture 01
 
Introduction to TDD
Introduction to TDDIntroduction to TDD
Introduction to TDD
 
Teldap4 getty multilingual vocab workshop2010
Teldap4 getty multilingual vocab workshop2010Teldap4 getty multilingual vocab workshop2010
Teldap4 getty multilingual vocab workshop2010
 
Measuring Code Quality in WTF/min.
Measuring Code Quality in WTF/min. Measuring Code Quality in WTF/min.
Measuring Code Quality in WTF/min.
 
Elixir Brasil 2019 - Quality: A Panacéia para seu código Elixir
Elixir Brasil 2019 - Quality:  A Panacéia para seu código ElixirElixir Brasil 2019 - Quality:  A Panacéia para seu código Elixir
Elixir Brasil 2019 - Quality: A Panacéia para seu código Elixir
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 

En vedette

Audit and Assurance Services - Jamaica AAS
Audit and Assurance Services - Jamaica AASAudit and Assurance Services - Jamaica AAS
Audit and Assurance Services - Jamaica AAS
Dawgen Global
 

En vedette (18)

Human Rights
Human RightsHuman Rights
Human Rights
 
People factor as failure reason of Agile adoption
People factor as failure reason of Agile adoptionPeople factor as failure reason of Agile adoption
People factor as failure reason of Agile adoption
 
Samsung SDS Retail Training
Samsung SDS Retail TrainingSamsung SDS Retail Training
Samsung SDS Retail Training
 
Design et expérience utilisateur sous SharePoint 2013
Design et expérience utilisateur sous SharePoint 2013Design et expérience utilisateur sous SharePoint 2013
Design et expérience utilisateur sous SharePoint 2013
 
Scalable Service-Oriented Middleware over IP
Scalable Service-Oriented Middleware over IPScalable Service-Oriented Middleware over IP
Scalable Service-Oriented Middleware over IP
 
Transforming the business value of internal communications through better mea...
Transforming the business value of internal communications through better mea...Transforming the business value of internal communications through better mea...
Transforming the business value of internal communications through better mea...
 
Design Thinking for Disruptive Innovation - Burton Lee - Kyiv - Oct 13 2015 -...
Design Thinking for Disruptive Innovation - Burton Lee - Kyiv - Oct 13 2015 -...Design Thinking for Disruptive Innovation - Burton Lee - Kyiv - Oct 13 2015 -...
Design Thinking for Disruptive Innovation - Burton Lee - Kyiv - Oct 13 2015 -...
 
XP (IT Brunch)
XP (IT Brunch)XP (IT Brunch)
XP (IT Brunch)
 
Enabling exploratory data science with Spark and R
Enabling exploratory data science with Spark and REnabling exploratory data science with Spark and R
Enabling exploratory data science with Spark and R
 
Leverage Mesos for running Spark Streaming production jobs by Iulian Dragos a...
Leverage Mesos for running Spark Streaming production jobs by Iulian Dragos a...Leverage Mesos for running Spark Streaming production jobs by Iulian Dragos a...
Leverage Mesos for running Spark Streaming production jobs by Iulian Dragos a...
 
Do you know what you are testing?
Do you know what you are testing?Do you know what you are testing?
Do you know what you are testing?
 
Spark Sql for Training
Spark Sql for TrainingSpark Sql for Training
Spark Sql for Training
 
Como criar sua Brand Persona para Social CRM
Como criar sua Brand Persona para Social CRMComo criar sua Brand Persona para Social CRM
Como criar sua Brand Persona para Social CRM
 
New base 980 special 28 december 2016 energy news
New base 980 special 28 december  2016 energy newsNew base 980 special 28 december  2016 energy news
New base 980 special 28 december 2016 energy news
 
Audit and Assurance Services - Jamaica AAS
Audit and Assurance Services - Jamaica AASAudit and Assurance Services - Jamaica AAS
Audit and Assurance Services - Jamaica AAS
 
Build your shiny new pc, with Pangoly
Build your shiny new pc, with PangolyBuild your shiny new pc, with Pangoly
Build your shiny new pc, with Pangoly
 
HDFS Internals
HDFS InternalsHDFS Internals
HDFS Internals
 
The Evolution of Recognition
The Evolution of RecognitionThe Evolution of Recognition
The Evolution of Recognition
 

Similaire à Code Reviews in Python - PyZh

Introduction to Python.pdf
Introduction to Python.pdfIntroduction to Python.pdf
Introduction to Python.pdf
Rahul Mogal
 
Code Quality Assurance v4 (2013)
Code Quality Assurance v4 (2013)Code Quality Assurance v4 (2013)
Code Quality Assurance v4 (2013)
Peter Kofler
 
Clean Code III - Software Craftsmanship
Clean Code III - Software CraftsmanshipClean Code III - Software Craftsmanship
Clean Code III - Software Craftsmanship
Theo Jungeblut
 
ch4-Software is Everywhere
ch4-Software is Everywherech4-Software is Everywhere
ch4-Software is Everywhere
ssuser06ea42
 
Slides for Houston iPhone Developers' Meetup (April 2012)
Slides for Houston iPhone Developers' Meetup (April 2012)Slides for Houston iPhone Developers' Meetup (April 2012)
Slides for Houston iPhone Developers' Meetup (April 2012)
lqi
 
Clean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code CampClean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code Camp
Theo Jungeblut
 

Similaire à Code Reviews in Python - PyZh (20)

Software maintenance PyConPL 2016
Software maintenance PyConPL 2016Software maintenance PyConPL 2016
Software maintenance PyConPL 2016
 
Python Linters at Scale.pdf
Python Linters at Scale.pdfPython Linters at Scale.pdf
Python Linters at Scale.pdf
 
[2011 CodeEngn Conference 05] Deok9 - DBI(Dynamic Binary Instrumentation)를 이용...
[2011 CodeEngn Conference 05] Deok9 - DBI(Dynamic Binary Instrumentation)를 이용...[2011 CodeEngn Conference 05] Deok9 - DBI(Dynamic Binary Instrumentation)를 이용...
[2011 CodeEngn Conference 05] Deok9 - DBI(Dynamic Binary Instrumentation)를 이용...
 
Code Quality Control in a PHP project. GeekTalks, Cherkassy 2020
Code Quality Control in a PHP project. GeekTalks, Cherkassy 2020Code Quality Control in a PHP project. GeekTalks, Cherkassy 2020
Code Quality Control in a PHP project. GeekTalks, Cherkassy 2020
 
Creating a reasonable project boilerplate
Creating a reasonable project boilerplateCreating a reasonable project boilerplate
Creating a reasonable project boilerplate
 
Introduction to Python.pdf
Introduction to Python.pdfIntroduction to Python.pdf
Introduction to Python.pdf
 
Linters for frontend code review
Linters for frontend code reviewLinters for frontend code review
Linters for frontend code review
 
Code Quality Assurance v4 (2013)
Code Quality Assurance v4 (2013)Code Quality Assurance v4 (2013)
Code Quality Assurance v4 (2013)
 
P4_tutorial.pdf
P4_tutorial.pdfP4_tutorial.pdf
P4_tutorial.pdf
 
Clean Code III - Software Craftsmanship
Clean Code III - Software CraftsmanshipClean Code III - Software Craftsmanship
Clean Code III - Software Craftsmanship
 
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
Safety on the Max: How to Write Reliable C/C++ Code for Embedded SystemsSafety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
Safety on the Max: How to Write Reliable C/C++ Code for Embedded Systems
 
OpenMetadata Webinar on Custom Connectors
OpenMetadata Webinar on Custom ConnectorsOpenMetadata Webinar on Custom Connectors
OpenMetadata Webinar on Custom Connectors
 
ch4-Software is Everywhere
ch4-Software is Everywherech4-Software is Everywhere
ch4-Software is Everywhere
 
Slides for Houston iPhone Developers' Meetup (April 2012)
Slides for Houston iPhone Developers' Meetup (April 2012)Slides for Houston iPhone Developers' Meetup (April 2012)
Slides for Houston iPhone Developers' Meetup (April 2012)
 
[DevDay2018] High quality mindset in software development - By: Phat Vu, Scru...
[DevDay2018] High quality mindset in software development - By: Phat Vu, Scru...[DevDay2018] High quality mindset in software development - By: Phat Vu, Scru...
[DevDay2018] High quality mindset in software development - By: Phat Vu, Scru...
 
Tech talks#6: Code Refactoring
Tech talks#6: Code RefactoringTech talks#6: Code Refactoring
Tech talks#6: Code Refactoring
 
Software maintenance PyConUK 2016
Software maintenance PyConUK 2016Software maintenance PyConUK 2016
Software maintenance PyConUK 2016
 
Angular v2 et plus : le futur du développement d'applications en entreprise
Angular v2 et plus : le futur du développement d'applications en entrepriseAngular v2 et plus : le futur du développement d'applications en entreprise
Angular v2 et plus : le futur du développement d'applications en entreprise
 
Security in CI/CD Pipelines: Tips for DevOps Engineers
Security in CI/CD Pipelines: Tips for DevOps EngineersSecurity in CI/CD Pipelines: Tips for DevOps Engineers
Security in CI/CD Pipelines: Tips for DevOps Engineers
 
Clean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code CampClean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code Camp
 

Plus de Cesar Cardenas Desales

Plus de Cesar Cardenas Desales (7)

PyConIT 2018 Writing and deploying serverless python applications
PyConIT 2018 Writing and deploying serverless python applicationsPyConIT 2018 Writing and deploying serverless python applications
PyConIT 2018 Writing and deploying serverless python applications
 
Migrate to Python 3 using the six library
Migrate to Python 3 using the six libraryMigrate to Python 3 using the six library
Migrate to Python 3 using the six library
 
PyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applicationsPyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applications
 
Writing and deploying serverless python applications
Writing and deploying serverless python applicationsWriting and deploying serverless python applications
Writing and deploying serverless python applications
 
Scalable Web applications with Elastic Beanstalk as your PAAS: a primer
Scalable Web applications with Elastic Beanstalk as your PAAS: a primerScalable Web applications with Elastic Beanstalk as your PAAS: a primer
Scalable Web applications with Elastic Beanstalk as your PAAS: a primer
 
Unit Testing with Nose
Unit Testing with NoseUnit Testing with Nose
Unit Testing with Nose
 
Distributed Task Processing with Celery - PyZH
Distributed Task Processing with Celery - PyZHDistributed Task Processing with Celery - PyZH
Distributed Task Processing with Celery - PyZH
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Code Reviews in Python - PyZh