Mรณdulo 27 ยท Design Patterns (All 23 GoF) โ Lecciรณn 2 de 23 ยท ~6 min
Factory Method
Let a method decide which object to build
Factory Method puts object creation behind a function so callers ask for what they want, not how it's made. When a booking update needs to go out, you don't want if channel == ... scattered everywhere โ you want one notifier_for(channel) that returns the right notifier.
In Python this is just a function that returns an object. No abstract creator class required โ a dict or an if/elif does the job.