Better Python Code: Ditch the Dictionaries
From ArjanCodes · · 20 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
🧱 Build software that lasts. Join the Software Design Mastery program → https://arjan.codes/mastery.
In this video, I refactor a Python booking system from loose dictionaries into a strict domain model using dataclasses, enums, and value objects. I show where stronger types improve maintainability, and where a simple string is still the right choice.
🔥 GitHub Repository: https://git.arjan.codes/2026/flexible.
💬 Join my Discord server: https://discord.arjan.codes.
⌨️ Keyboard I’m using: https://amzn.to/49YM97v.
🔖 Chapters: 0:00 Intro 0:30 The Working Before Version 1:42 The Core Design Lesson 2:55 Step 1: Replace the Dictionary 6:04 Step 2: Split Out Domain Concepts 8:38 Step 3: Replace Magic Strings 10:18 Step 4: Add a Money Value Object 13:46 Step 5: Move Rules Near the Concept 15:19 Step 6: Clean Up the Business Function 15:36 Step 7: Validate at the Boundary 17:52 Keep One String on Purpose 19:04 Why This Improves Maintainability 19:44 The *kwargs Design Smell 20:20 Final Thoughts
#arjancodes #softwaredesign #python