plug in behaviors has-a
move behavior
attack behavior
defense behavior
Shield off
act
class Character one object
๐Ÿ›ก๏ธ
hero
holds 3 behavior objects ยท no subclass
๐Ÿƒ move โ€”
โš”๏ธ attack โ€”
๐Ÿ›ก๏ธ defense โ€”
with inheritance is-a
To cover every combination you'd need one subclass per combination:
3 ร— 3 ร— 2 = 18 subclasses
+ add an armor axis (ร—3) off
composition needs only
3 + 3 + 2 = 8 behavior objects
console
โ–ธ One Character object holds swappable behaviors. Change a dropdown and the abilities update live โ€” no new class. The right panel shows how many subclasses inheritance would need instead.