Briefle words · Code & architecture
Strategy pattern
Putting one interchangeable behavior behind a common interface so it can be swapped without changing the code that uses it.
Say it to an AI
TypeScript Enemy model for a shoot-'em-up using composition over inheritance: one Enemy class that takes a movement and a list of abilities behind a shared Ability interface (strategy pattern). No subclasses per combination like FlyingShooterEnemy.
How an expert would brief the stronger version of “Game enemies”.
See it
Try it as a puzzle →A mobile shoot-'em-up models enemies that walk or fly and can shoot or heal.
Why: B's 'Ability' interface lets 'Fly', 'Shoot' and 'Heal' plug into the same 'update()' loop.
Related words
Room 3 · Functions & structure
Learn “Strategy pattern” in a five-minute lesson