Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Code Review of Senior Python Engineers

Code Review of Senior Python Engineers

Through various practical experiences and case studies, this talk aims to share with professional software engineers the output and expectations of "seniority" in code submission (pull-request) and code review at each stage of software development.

Specifically, it covers: 1. Key points of writing and reviewing Python code. 2. Related environment, tools, and methods.

In the summary, the talk will also move from the perspective of a senior engineer's Python code review to the communication, learning, sharing, and recruitment within an organization. Enough time will be assured for Q&A by best effort.

Keith Yang

August 19, 2023
Tweet

More Decks by Keith Yang

Other Decks in Programming

Transcript

  1. Agenda Six Key Points of Senior Python Code Review Supportive

    Environment and Tools around Pull-Request 1. 2. 2023 talk in PyCon TW
  2. Pull-Request (PR) > A pull request is a method used

    in collaborative coding projects to propose code changes. > It allows developer to request code review, and then merge those changes into the main code repository once approved.
  3. Keith Yang Lead Backend Engineer in iCHEF Taipei.py co-founder and

    co-organizer PyCon APAC 2015 Chairperson Lead Backend Engineer in iCHEF Taipei.py co-founder and co-organizer PyCon APAC 2015 Chairperson
  4. ... to submit a change to the kernel, ... can

    be daunting ... if not familiar with "the system" - Submitting patches guide (Linux kernel) git send-email
  5. #Comment Code Readibilirty Make code easy to be understood If

    it's tricky, write comments to help understanding 1st key point
  6. Uniqueness "user" in users.py "member" in members.py "user" in crm.py

    "member" in crm.py Easiest to find and reason? a. b. c. d.
  7. Uniqueness "user" in users.py "member" in members.py "user" in crm.py

    "member" in crm.py Easiest to find and reason? a. b. c. d. Tool: ripgrep
  8. Code & Infra Readability Make code and module easy to

    understand If it's tricky, write comments and doc to help understanding
  9. 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. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those! The Zen of Python, by Tim Peters python3 -m this
  10. Beautiful is better than ugly. Explicit is better than implicit.

    Simple is better than complex. CODE CODE NAMING NAMING COMMENT COMMENT
  11. CODE NAMING COMMENT Readability counts. ...easy to explain, it may

    be a good idea Namespaces are one honking great idea
  12. Unused Code Linting Tools: ruff, flake8, pylint Avoid writing unused:

    variables imports functions classes 4th key point
  13. Senior Wrote Knew Common Python Errors Defaults for function arguments

    Modifying a list while iterating over it Lambda in for loop? MISTAKES 5th key point
  14. Type Hint But it can be used to find mistakes

    early Small Projects v.s. Large Enterprise Projects No. extra key point
  15. “One essential characteristic of modern life is that we all

    depend on systems” -- The Checklist Manifesto: How to Get Things Right by Atul Gawande
  16. Why to and why not Commit Message Pull-Request Description Document

    File Documentation Documentation Complete the Code Review
  17. Purposes and Reasons Implement Plan Do This B efore Coding

    Design Review Design Review Complete the Code Review
  18. Operation Review Scop User Stories Security Review Inspirations Success Criteria

    B Plan (if not working) Designs (API, Model, DB) Performance Review Alternatives Considered Template Example & Tips
  19. Document Tool Exmaple Document Tool Exmaple .TXT, .md, .rst Notion,

    Amplenote, ... Notion, Google Doc, CryptPad, ... Figma, Archi, ...
  20. CI / CD Continuous Integration Continuous Deployment Code ⬇️ Build

    ⬇️ Test --- ⬇️--- Staging ⬇️ Production
  21. CI / CD Tool Example CI/CD pipelines Jenkins GitHub Actions

    PipeRider.io (data, dbt) pre-commit flake8, ruff, black, isort
  22. "Spot issues before they emerge" ~ PipeRider ( instead of

            Hotfix on Production )
  23. Errors should never pass silently Unless explicitly silenced Special cases

    aren't special enough to break the rules DOCUMENT DOCUMENT TEMPLATE TEMPLATE CI / CD COVERAGE CI / CD COVERAGE
  24. Errors should never pass silently Unless explicitly silenced Special cases

    aren't special enough to break the rules DOCUMENT DOCUMENT TEMPLATE TEMPLATE CI / CD COVERAGE CI / CD COVERAGE TYPE HINT TYPE HINT
  25. DOCUMENT TEMPLATE CI / CD There should be one --

    and preferably only one -- obvious way to do it. TYPE HINT
  26. AI Tools Prompt vs real experienced Domain Knowledge Identify what's

    right and wrong with official doc Experiment tools and grow with your team
  27. Internet AI Books, Podcast, Video ( O'Reilly Learning) Communities &

    (Py)Cons Different Languages & Design Paradigms & Pitfalls def Learning(self) Taiwan /APAC
  28. Search on Internet Reference vs Pragmatic Mentor & Boss Interview

    & Culture Care Framework Care Framework Ladder: Your Mileage May Vary
  29. Summary From Comment to Naming: Explicit Common Errors Supportive Environment

    with Tools: Find Errors at Very First Place Design Template CI/CD, AI, Soft Skills Senior: More Helpful