Polymorphism Over Discrimination

Find and fix code that decides what to do by asking what something is. Use this skill whenever reviewing or writing Python that contains an isinstance chain, an `if mode == "x" / elif` chain, `if record.field is None` where the arms do different work, a validator that rejects field combinations ("X is only valid when Y is Z"), a function returning a string that names an operation, or a record carrying a kind flag plus fields belonging to only one kind. Use it when adding an arm to any existing chain of those, when adding an optional field to a type you own, when introducing a `Missing`/`No`-prefixed class, and when naming something Builder, Factory, Strategy, or Visitor. Also use it for any request to review Python design, reduce branching, clean up conditionals, or audit a package for structural problems — even when the user does not say "polymorphism". Python only.

wolski Updated

File contents

wolski/wews_skill_coordinator/tree/main/skills/software-engineering/skills/polymorphism-over-discrimination commit bd57b0318f

Frequently asked questions

npx skillmds@latest add wolski/polymorphism-over-discrimination