Too Many Function Arguments? Use This Pattern
From ArjanCodes · · 19 min

The player loads from YouTube only when you click. It uses YouTube's privacy-enhanced mode.
If the video does not play, the owner may have turned off embedding. Watch it on YouTube instead.
Description
💡 Learn how to design great software in 7 steps: https://arjan.codes/designguide.
Tired of passing five arguments to every function? In this video, I clean up a realistic Python codebase using the Context Object Pattern. You’ll see how to go from messy, repetitive function signatures to a cleaner and more maintainable design. We’ll introduce context objects, explore how they help reduce parameter bloat, discuss the trade-offs (like increased coupling), and show how to use Protocols to keep things decoupled and testable.
🔥 GitHub Repository: https://git.arjan.codes/2025/context.
🎓 ArjanCodes Courses: https://www.arjancodes.com/courses.
💬 Join my Discord server: https://discord.arjan.codes.
⌨️ Keyboard I’m using: https://amzn.to/49YM97v.
🔖 Chapters: 0:00 Intro 1:07 The Before Version: Too Many Arguments 3:43 Introducing the Context Object Pattern 9:35 But Wait — Aren't We Adding a Bunch of Coupling? 10:56 Making a Distinction Between High-Level vs Low-Level Code 13:33 High-Level Convenience, Low-Level Clarity 15:07 Using Abstraction 17:22 When Should You Use Context Objects? 18:51 Final Thoughts
#arjancodes #softwaredesign #python