145

Seeing that Uncle Bob is making a new version of Clean Code I decided to try and find this article about the original.

you are viewing a single comment's thread
view the rest of the comments
[-] Lysergid@lemmy.ml 8 points 3 months ago

Folks really trying to argue about example code. Even created “global state” straw man. Here is secret - if you are using global state then code is shit in the most cases.

[-] BatmanAoD@programming.dev 7 points 3 months ago

It's not a strawman, though, because Martin's actual example code in the book is like this, including a full module he rewrites toward the end.

[-] FizzyOrange@programming.dev 2 points 3 months ago

When they say global state here it's not really global state, it's class members - global to the class. "Why are they calling it global state then, idiots?" you might think. It's because it prevents local reasoning in the same way as global state does (and most people get the implications of "global state" because of experience, so it's a kind of shorthand).

Of course, not many people would recommend "no class variables" (in a classic OOP language anyway), but the point is they have similar downsides to global variables in terms of understanding code (and testing, etc.) so recommending to always use them - even when passing state in and out of functions is perfectly ergonomic - is clearly bonkers.

this post was submitted on 10 Aug 2024
145 points (95.0% liked)

Programming

17314 readers
8 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 !webdev@programming.dev



founded 1 year ago
MODERATORS