A cross-platform app team shipped a Windows build with one macOS checkbox in it. Not a wrong color — a different widget: rounded where every other control was square, animating on a curve nothing else used. It slipped through because the checkbox was created three files away from the button, each by its own if (platform == ...), and someone updated the button switch but not the checkbox one. The build was green. The screen was wrong.
The bug isn’t the mismatched widget. It’s that nothing in the code made the match required. Each control decided its own platform independently, so “keep the whole UI consistent” was a rule that lived in the developers’ heads and nowhere in the type system. The moment you have a family of things that must agree with each other, scattering their construction across independent switches is a consistency leak waiting to happen. The Gang of Four named the fix.
The intuition: order the combo, not the parts
Walk into a restaurant and order the “Italian set menu.” You don’t assemble it yourself — pasta from here, dessert from there, wine picked at random. You point at one menu, and the kitchen hands back a spread that’s designed to go together. Switch to the “Japanese set menu” and the entire spread changes at once: different starter, different main, different drink — but still a coherent meal. You never end up with tiramisu next to miso soup, because you were only ever allowed to choose the menu, not the individual dishes.
The menu is the abstract factory. Each dish is a product. The guarantee you’re paying for is that the parts always match — because you pick the family, and the family comes complete.
From here the members-only walkthrough gets concrete: the load-bearing “family” idea, a live interactive kit where one click swaps the whole product set, the class diagram and full code, the add-a-family-vs-add-a-product tradeoff, the Abstract Factory vs Factory Method distinction, a cloud-provider refactor challenge, and an interview corner.
Keep reading with Premium
You've reached the members-only part of this deep-dive — the full implementation, the interactive ring simulator, and the step-by-step walkthrough. Unlock it with a membership.
Discussion
Loading the conversation…
Discussion
Loading the conversation…