Welcome to Hell Cue the theme song from The Fresh Prince of Bel Air. This is a story that turns out well. But my code got stuck in import hell. I tried to teach my students all about pytest. Instead, for two days, I was sent on a debugging quest. I teach middle school students… Continue reading Stuck in import hell? Walk your way out.
Articles on refactoring
Write more maintainable Python code, avoid these 15 code smells
By PyBites Team on 15 September 2023
This week we talk about code smells. 💡 Listen here: Also available on our YouTube channel: Code smells are characteristics in the code that might indicate deeper issues or potential problems. While they’re not necessarily bugs, they can be a sign of poor code quality or maintainability issues. 😱 We distilled 15 common smells ranging… Continue reading Write more maintainable Python code, avoid these 15 code smells
When to refactor your code?
By Rob van der Leek on 11 August 2023
How to make refactoring part of your Definition of Done Writing code is an iterative process. The first iteration is usually not the best result. Grooming and polishing ✨ are needed before the code is ready to share with the world (and your future self). There is a saying in software development that illustrates the… Continue reading When to refactor your code?
How the Flocking Rules Can Help You Refactor Your Code
By PyBites Team on 10 August 2023
In this new podcast episode we are excited to have Chris May back to delve deeper into the intricacies of refactoring. Watch here: Listen here: We talk about the significance of the Flocking Rules, a set of guidelines derived from “99 Bottles of OOP” by Sandi Metz and Katrina Owen. These rules provide developers with… Continue reading How the Flocking Rules Can Help You Refactor Your Code
Why is Flat Better Than Nested? (Zen of Python)
By Bob Belderbos on 1 August 2023
The short answer: deeply nested code can be hard to read and understand (and this not only applies to Python, but for any code really). Each level of indentation adds a level of complexity and an additional condition that the reader (which is often you!) has to keep in their head while trying to understand… Continue reading Why is Flat Better Than Nested? (Zen of Python)
The importance of refactoring regularly [podcast]
By PyBites Team on 15 June 2023
In this episode we talk with Chris May, Python developer and coach, about his background and passion for refactoring. Watch here: Or listen here: This turned into a beautiful love letter 💌 to refactoring and we think you should take notice, because adopting the mindset he teaches will improve your code. A lot! Enjoy and… Continue reading The importance of refactoring regularly [podcast]
Tips for clean code in Python
By Bob Belderbos on 8 November 2022
In this article I will give you 10 tips for cleaner code. Hope this helps improve your Python code. 1. Smaller units. Break long functions (methods) into multiple smaller ones that do one thing (SRP or “Single-responsibility principle”). This will make your code more modular and easier to test. For example, a function that parses… Continue reading Tips for clean code in Python
Help, I need to refactor a mega class! Here are 5 tips …
By PyBites Team on 24 September 2022
Somebody asked the other day for tips on how to refactor a mega-class? It was actually one of the first tasks on the new job, ouch! A single class, several thousands lines of code, no tests available 😮 You might scratch your head and say WTF?! After all, good developers decouple code into manageable pieces… Continue reading Help, I need to refactor a mega class! Here are 5 tips …
A Case Study in Refactoring Python: Clean Code Is Often Faster
By Russell Helmstedter on 20 July 2022
I have learned a lot over the past 2.5 years of my Python journey. What started out as a hobby during COVID-19 lock downs in 2020, has now become a major component of my professional workload. This article is designed to highlight the importance of the iterative process: write some code -> learn new stuff… Continue reading A Case Study in Refactoring Python: Clean Code Is Often Faster
Refactoring Opportunities That Will Boost the Quality of Your Code
By Bob Belderbos on 19 April 2020
Refactoring is all about making your code more maintainable. In this article I will provide you with Python and generic software tips to write better code.