this post was submitted on 28 Sep 2024
1125 points (99.0% liked)

Programmer Humor

32259 readers
168 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 5 points 2 weeks ago* (last edited 2 weeks ago)

IMO, the most important parts are to document the actual intent of the code. The contract of what is being documented. Sure, it's only so useful in perfectly written code, but NO code is perfect, and few will come through later with full context already learned.

It makes it sooo mich easier to know what is intended behavior and what is an unchecked edge case or an unexpected problem. If it's a complicated thing with a lot of fallout, good documentation can save hours of manually lining up consequences and checking through them for sanity.

You might say, "but that's indication of bad code!". No. Not really. Consequences easily extend past immediate code doing things as trivial as saving data to the database without filtering, or having a publicly available service. Even perfectly coded things come up with vulnerabilities all the time due to underlying security issues. It's always great to have an immediate confirmation of what's supposed to happen whether it's immediate code or some library with a new quirk in a new version.