• cynar@lemmy.world
    link
    fedilink
    English
    arrow-up
    19
    arrow-down
    1
    ·
    1 year ago

    To me, the one of the right is FAR more readable. At least if your intention is to understand what it does.

    For the left-hand one, you have to read all of it to understand its flow. For the right-hand one, just the first function is enough. You now know what it’s doing, and how (roughly) it’s doing it. Each subsequent function then explains a step, in detail. This allows you to focus, say, on cooking, without any understanding of the preparation phase, or the boxing phase. This vastly reduces the cognitive load, and lets me focus in on the small details.

    This same set of properties is also what makes the right hand one easier to maintain. It lets you treat parts as black boxes, you don’t need to know, or care, what goes on inside. You can work on 1 with minimal references to other parts. E.g. the oven could be a simple warm up, cook, cool down cycle. However it could also be a complex, machine learning driven system, governing 100s of concurrent ovens and 10,000s of pizza for optimal cooking speed, energy use and maintenance requirements. Outside of the function, I don’t need to care. It’s just “Give me an oven, wait, here’s your cooked pizza”.