plug in
behaviors
has-a
move behavior
Walk
Fly
Swim
attack behavior
Sword
Laser
None
defense behavior
Shield
off
act
โธ simulate turn
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
Reset
โธ
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.