pnutzh4x0r@lemmy.ndlug.org to Programming@programming.devEnglish · 10 months agoLinear code is more readableblog.separateconcerns.comexternal-linkmessage-square46fedilinkarrow-up1134arrow-down115 cross-posted to: hackernews@lemmy.smeargle.fanshackernews@derp.foo
arrow-up1119arrow-down1external-linkLinear code is more readableblog.separateconcerns.compnutzh4x0r@lemmy.ndlug.org to Programming@programming.devEnglish · 10 months agomessage-square46fedilink cross-posted to: hackernews@lemmy.smeargle.fanshackernews@derp.foo
minus-squarerobinm@programming.devlinkfedilinkarrow-up1·edit-210 months agoOne way to make it obvious which function can be called at which state is to use different type. Like UnbackedPizza and CookedPizza, and the bake function takes the former and returns the later.
One way to make it obvious which function can be called at which state is to use different type. Like
UnbackedPizza
andCookedPizza
, and thebake
function takes the former and returns the later.