Too Many, Too Expensive
A stadium's ticket map has 50,000 seats, and an app opens database connections like they're free. Some things are worth sharing.
Updated
Share What's the Same
- Flyweight: Share What's the Same (Journeyman): When thousands of objects each carry their own copy of the same few details, memory grows with every object; the Flyweight pattern stores what's the same once per kind and shares it, so each object keeps only what's its own.
Share What's Expensive
- Object Pool and Lazy Loading: Make It Once, Share It, or Make It Late (Journeyman): When something slow to make is made for every request, or something big is made at the start and hardly used, the app slows down or runs out; an object pool makes a few and lends them out and back, and lazy loading makes a thing the first time it's needed, then keeps it.
Exercise: The Stadium Seat Map
- Exercise: The Stadium Seat Map (Freelancer): Take a ticket from Harbor Stadium's kiosk team: the festival's 200,000-place seat map has to fit in 10 MB on the gate tablets. Change the working seat map so seats of the same kind share their details, with the tests green throughout.