Danny Preussler
Dec 7, 2019 · 1 min read

The point in the original article was to not have inheritance for the Door. If its open or closed is a state so should be using composition.
You could have open and close methods directly on the DoorState but that should be hidden via door as you open a door not a door state.
So making it safe at compile time (without a runtime when/switch) is the tough part here

    Danny Preussler

    Written by

    Android @ Soundcloud, Google Developer Expert, Conference Nomad, Geek, Goth, Cyborg, Ex @Viacom @Groupon @eBay ♡ Kotlin ♡ TDD ♡ Clean Code