Contenu connexe Similaire à Code Reviews in Python - PyZh (20) Plus de Cesar Cardenas Desales (7) Code Reviews in Python - PyZh1. Code Reviews in Python
César Cárdenas Desales
Zürich Python User Group, June 2016
2. 2
About me
● Software Architect at Webrepublic AG
● Python user since v.2.0
● Co-organizer of the Swiss Python Summit
3. ¿What are Code Reviews?
3
Systematic examination of computer source code…
- Wikipedia
5. Timeless
5
● Being here for a while (Fagan, 1976)
● Not going away any time soon
● Technology agnostic
● Not a fad
6. 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
9. Increase quality of software
9
● Reviewed solutions tend to be better
● Defects are found and fixed early
Source: IBM Systems Sciences Institute
12. 12
Code Review with Github
Implementation
Pull
Request
Discusion
Preparation Revision Closure
Revision
Merge
Branch
12
Commit
17. 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
19. Code conventions and style guides
Criteria - Pythonic code
19
Pythonic code
pycodestyle / Flake8 / Pylint
20. Code conventions and style guides
Criteria - Pythonic code
20
Pythonic code
pycodestyle / Flake8 / Pylint
21. 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.
...
29. Automated unit tests: unittest / pytest / nose / coverage
Criteria
29
Efficient algorithms
Edge cases / off by 1 errors
Duplicated code / copy & paste