On Thursday, 20 July 2023 at 21:26:55 UTC+2, ed de moel wrote:
When it comes to comments, I always am reminded of a snarky observation by one of my professors in college:
"If the code and the comments disagree, then both are probably wrong..."
That aside: I have seen too many comments that just replicate the code. That is a waste of bandwidth.
Comments should explain WHY you're doing the things the way you chose.
So: explaining the meaning of parameters, and their ranges of acceptable values is a GOOD thing.
But, such a comment that just says "A string between 5 and 20 characters" is a waste of effort.
In the above example: width of the frame; default 50... what's missing is "in which units?" What is "too small"? what is "too big?"
and so on... I'm sure you get the idea.
Just my $0.02,
Ed
Yeah, you got a point there. The M-Unit tests actually explains more about what the routine does than the actual routine itself.
The example I posted above is a pure example of which ways the routine could be used. At the moment I pretty much write an "documentation essay" of some routines that I KNOW I will forget how it even works after a year - since Mumps-code is really "
cryptic" sometimes and really hard to understand what it does from the get-go.
But some M-Unit Tests is a good idea for "documentation-purposes" and also to maintain the functionality of the routines, so nothing breaks in the future.
I also strive to build more "Generic" Util routines that can be re-used in other places since it goes against my philosophy that a routine/function/whatever is only being used once and never again.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)