this post was submitted on 15 Sep 2023
120 points (90.5% liked)

Programming

17553 readers
327 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 23 points 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".