Lecture: Washing away code smells
Does your code smell? Have a weird fragrance? It turns out code smells are a real thing and an amazing conceptualization of suboptimal design. This talk helps you develop you code nose through identifying Python code smells. It also shows you how to wash them away by the technique of refactoring. You will learn the art of writing Pythonic, clean and maintainable code.
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:
Unnecessary long and complex code
Knowing what to refactor, I will share a few learnings that lead to good quality code:
The boy scout rule - always leave the code cleaner than you found it
Good practices in Python
Good use of data structures
The art of naming
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.