Skip to main content
AmigoFish

This Design Pattern Replaces an Entire Class Hierarchy

From ArjanCodes · · 15 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.

Watch on YouTube

Not rated yet

Description

🧱 Build software that lasts. Join the Software Design Mastery program → https://arjan.codes/mastery.

What should you do when objects differ by type: create subclasses, store an enum like plan_type, or represent each variation as an object? In this video, I use a realistic Python subscription system to compare all three approaches and introduce the Type Object pattern.

🔥 GitHub Repository: https://git.arjan.codes/2026/type.

💬 Join my Discord server: https://discord.arjan.codes.

⌨️ Keyboard I’m using: https://amzn.to/49YM97v.

🔖 Chapters: 0:00 Intro 2:22 Approach 1: Model the Variation With Subclasses 3:47 Approach 2: Just Store the Type 5:47 Approach 3: Make the Type an Object 8:51 Why Not Just Use the Enum? 9:45 Where Do the Type Objects Live? 14:09 Choosing Between the Three 15:05 Final Thoughts

#arjancodes #softwaredesign #python

Back to ArjanCodes · Report a problem