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

Programming

17432 readers
115 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 1 year ago
MODERATORS
 

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
[–] [email protected] 2 points 3 months ago (8 children)

If those functions are huge units of work or pretty complex, I can agree. For most cases though, a simple code comment should do to explain what's going on?

[–] [email protected] 4 points 3 months ago (7 children)

Comments should never be about what is being done. They should only ever be about why it is being done.

If you write your code like suggested in the book, you won't need to rely on possibly outdated comments to tell you what's going on.

Any comment about "what is being done" can be replaced with extracting the code in question to a separate, well-named method.

[–] [email protected] 7 points 3 months ago (2 children)

I disagree about comments should never be about what is being done. If what is being done is not obvious then they're important. Take assembly code as an example. Or complicated bit operations. I agree the why is more important to document than the what but saying the what is never important seems misguided.

Also, this may be a semantics thing, but oftentimes the code's specification is in doc comments. I don't believe you're claiming code shouldn't ever have specifications, this isn't meant as a gotcha lol.

[–] [email protected] 1 points 3 months ago (1 children)

You're talking about assembly in a thread about OOP...

[–] [email protected] 1 points 3 months ago

I think commenting what can be important in OOP too though.

load more comments (4 replies)
load more comments (4 replies)