Module 08 · System Design · Low-level design: classes, properly
Swap the rule, keep the class (Strategy and Factory)
Swap the Rule, Keep the Class · Open board
The elif chain copied into three pages, the four rule cards that replace it, and the table that makes them.
Before you start. You need a few ideas from earlier in this track. A class is a blueprint for objects. A constructor is the code that runs once when an object is made, written __init__ in Python. Has-a beats is-a (composition over inheritance) showed an object keeping another object inside it and passing requests to it, so that part can be replaced later. Five letters, one shop (SOLID) gave the rule called open for extension and closed for editing: add new behaviour by adding code, not by changing code that is already tested. This lesson turns both into two named moves.
Lesson 39 of 73 in System Design
The rest of this lesson is part of a plan.
A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year, or $19.50 for your first year with LAUNCH50, ends 1 Nov, 18:30 UTC.