How to Lift Your Tech Debt Curse with the Magic of the Open-Close Principle
summary
Claim: apply the Open-Closed Principle to refactor fragile Python production code without changing behavior, using small, tested steps. The code example transforms a single get_payment function into a DateRange dataclass, an Order parameter object, extracted helper methods, a notification decorator, and a location-specific subclass for discount logic. Refactoring shrinks the long method, shortens the parameter list, removes magic numbers, and preserves results after each change. Recommended tooling: dataclass and parameter object, extracted methods and tests.
AI-written summary · about
chapters (7)
- 0:00Introduction and story
- 2:14Tech debt curse explained
- 3:18Code smell examples
- 7:35Refactoring for clarity
- 13:15Refactoring principles
- 15:45Open-Close Principle
- 17:33Conclusion and simplicity
related talks
44mRefactoring from Good to Great
47mRefactoring from Good to Great
31mTechnical Lessons Learned from Pythonic Refactoring
33mElegant Solutions For Everyday Python Problems
57mTechnology mix: From legacy to clean architecture
48mRefactoring from Good to Great - A Live-Coding Odyssey
47mHow to Fix Your Technical Debt Dilemma
24mOpen Close Principle, is it what you thought?
