0
Challenge · 81CS Fundamentals
SOLID, lightly
OOPused in ~75% of apps
Five principles with an acronym, and a real risk of being asked to recite them. Reciting five sentences is a weak answer. Knowing what each one prevents, and being able to name the two that actually change code you write, is a strong one.
Core idea. SOLID is five rules about where change hurts. Each one names a way that adding something later forces you to edit something that already works, and each one says how to arrange the code so it does not.
poke it, drag it,
try to break it
try to break it
no slides here.
you drive.
you drive.
Playground, this isn't a screenshot
tick the behaviours an item needs
with inheritance
class PlainItem
One class per combination. Three behaviours need 8 classes, and a fourth needs 16.
with composition
traits: []
One item, a list of behaviours. Three behaviours need 3 functions, and a fourth needs 4.
Inheritance grows as two to the number of behaviours. Composition grows as the number of behaviours.
↑ play a little first, then dig in