1532
you are viewing a single comment's thread
view the rest of the comments
[-] nosurprises@lemm.ee 13 points 1 year ago* (last edited 1 year ago)

Code is the documentation. Any other form of documentation requires additional maintenance and becomes obsolete quickly.

[-] vox@sopuli.xyz 5 points 1 year ago

all functions should at least have doc comments on them

[-] magic_lobster_party@kbin.social 1 points 1 year ago

No. Just give the function a good descriptive name with good descriptive parameters. Keep the function simple too. If you can’t, try to refactor and see if that helps.

If you are still unable to express yourself via code, then you should use comments to guide the reader.

[-] auchschonda@feddit.de 2 points 1 year ago* (last edited 1 year ago)

What about exceptions raised within the function? Will you also put them in the descriptive function name? ;)

[-] magic_lobster_party@kbin.social 0 points 1 year ago

You can find them by reading the code. It’s not difficult if they’re placed at proper locations.

[-] auchschonda@feddit.de 2 points 1 year ago

But a major point of a function is that you not have to read its implementation details.

[-] magic_lobster_party@kbin.social 1 points 1 year ago

According to who? If I have access to the source code, which I often do, I’d rather just read the code. Chances are that if documentation exists, it’s no longer up to date.

[-] auchschonda@feddit.de 2 points 1 year ago

Modularity. Part of it is defining a proper Interface for using the hidden complexity.

Exceptions are only one example. Functions can have behavior, inner states, prior calling requirements etc.. you cannot read from its mere prototype.

Do you really want everyone to read the inner code to learn that?

Chances are that if documentation exists, it’s no longer up to date.

This risk also applies to descriptive function names. They can be poor, wrong or outdated, too.

load more comments (3 replies)
load more comments (3 replies)
load more comments (17 replies)
this post was submitted on 02 Oct 2023
1532 points (98.4% liked)

Programmer Humor

32171 readers
728 users here now

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

Rules:

founded 5 years ago
MODERATORS