Technical Lessons Learned from Pythonic Refactoring

Yenny Cheung (@yennycheung)

Yenny Cheung, Software Engineer, Biz National, Yelp

Originally from Hong Kong, Yenny moved to Pennsylvania in the US to study Computer Science at Swarthmore College. She attended the Grace Hopper Conference three times during her college years. After graduation, Yenny moved to Hamburg and joined Yelp as a full-stack software engineer. Yenny works on the Biz National team, where she is scaling advertising tools and reporting for multi-location businesses and franchises. She is a pioneer of the Awesome Women in Engineering Group at Yelp in Germany and she is active in Women in Engineering Meetups in Hamburg. Outside of work, Yenny enjoys yelping for good food and painting. </div>

Abstract

Tags: code smell api refactoring python web

Ever stumbled upon poorly-maintained codebases that suck away your productivity? Fear no more! This talk addresses how to identify code smell (from Brie to Bleu cheese) and go through examples to refactor code and APIs. You will learn the art of writing clean, maintainable and idiomatic Python code.

Description

This talk targets beginner software engineers yet also aims to provide interesting content for more advanced developers. You will leave knowing more about code smells and understanding the whys and hows of refactoring.

Code smells refer to the symptoms of problematic code design. Identifying different types of code smells is the first step to successful refactoring. I will talk through some classic examples:

  • Unnecessarily complex code
  • Inappropriate naming
  • Duplicated code
  • Non-modularized code

Knowing what to refactor, I will share a few learnings that lead to good quality code:

  • Good python practices (The Zen of Python & PEP8)
  • Good use of data structures (named tuples & sets)
  • The art of pythonic naming
  • DRY principle
  • Separation of concerns principle (modularity & encapsulation)

Refactoring also makes testing easier. I will discuss how to write unit tests that cover all use cases. Finally I will talk about integration testing strategies that ensure that you and people who want to modify your API in the future are not breaking upstream code.