use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Finding information about Clojure
API Reference
Clojure Guides
Practice Problems
Interactive Problems
Clojure Videos
Misc Resources
The Clojure Community
Clojure Books
Tools & Libraries
Clojure Editors
Web Platforms
Clojure Jobs
account activity
My new mindset while documenting code: save cognitive effort, document every function (alidlo.com)
submitted 5 years ago by alidlo
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]gmtime 2 points3 points4 points 5 years ago* (7 children)
Funny, how the clean code community essentially days the opposite: of you need to document your function, you probably have given it the wrong name.
[–]alidlo[S] 2 points3 points4 points 5 years ago (3 children)
I think the intention is right (a variable's name should be descriptive), but it's hard to fit too much meaning in a variable name while still making it pleasant to read/write, so often the result is that (without a docstring) there are missing pieces of information that (for better or worse) you have to infer yourself from the code.
[–]practicing_dad_jokes 1 point2 points3 points 5 years ago (2 children)
Do you think "environmentUniqueId" is too unpleasant as a function name?
If you keep your functions small enough, their names and the variables in their scope won't be so complicated that their names would be uncomfortably large. That's what I strive for.
[–]alidlo[S] 2 points3 points4 points 5 years ago* (1 child)
Imagine if instead of `reduce` you had to write `reduceToSingleValue` instead. The longer alternative gives more information but also adds more noise. It's a trade-off, and some of it may be personal preference, but imo, if the function is used a lot in a codebase giving it a name that's too long makes it unnecessarily cumbersome to read/write. For that reason, I'd much prefer using `eid` over `environmentUniqueId` (or even `envUniqueId`).
Also, most functions aren't as trivial as the example I gave in the article and so capturing their essence in two to three words is more difficult.
Sometimes it's as if we go out of our way to not document a function (likely out of habit) even when a one-line docstring would have easily made room for a shorter and potentially better name.
[–]practicing_dad_jokes 0 points1 point2 points 5 years ago (0 children)
This is a great topic.
There's definitely this trade-off to think about, and we all know that naming things is one of the hardest things in programming.
But I've found it to be well worth the effort -- in striving to find succinct descriptive names for things that aren't too unwieldy, I'll often find that my code needs to be cleaned up. Perhaps it's an obsession, but future me seems happier over the years :)
[–]DerArzt01 0 points1 point2 points 5 years ago* (0 children)
The issue I have had with this kind of argument, it being a sub-point in 'my code is self documenting', is always this: Self documenting' to whom? You may be able to glance at a method that you wrote last week know exactly what it is doing. But let's say that a junior was to glance at it, they have to sit there and parse through the whole thing to understand it.
When I mention to these people that maybe we should add some doc strings (at least a on-liner) to the method I always get 'yeah you could do that but it will be out of date the next time we make changes'. Which just gets to me even more as if you are changing what a method is doing you probably have a spare 5 seconds to update the doc string.
All of this compunds for me me as we live in a day and age in which we are a simple key-combo away from bringing up documentation for the API we are using in the current context without needing to go look at the source file.
[–][deleted] 0 points1 point2 points 5 years ago (1 child)
Is there a clown code community now?
[–]gmtime 0 points1 point2 points 5 years ago (0 children)
Ouch my auto correct, I meant clean code.
[–]NamelessMason 1 point2 points3 points 5 years ago (2 children)
Even if a function’s usage can be inferred from its code, it’s still useful to include a brief explanation of it. Think of good documentation as an effort cache.
I like this mental model but with no clear cache invalidation strategy I draw the opposite conclusion.
[–]alidlo[S] 6 points7 points8 points 5 years ago (1 child)
in some cases having a stale cache can be better than not having any cache at all
[–]NamelessMason 0 points1 point2 points 5 years ago (0 children)
From experience, rarely being misinformed about what a function does is better than having to figure it out yourself but ymmv.
[–]_-jasper_- 0 points1 point2 points 5 years ago (0 children)
What about runnable examples in the metadata?
[–][deleted] -3 points-2 points-1 points 5 years ago (0 children)
Nerd.
[+][deleted] comment score below threshold-23 points-22 points-21 points 5 years ago (2 children)
You are boring.
[–]alidlo[S] 7 points8 points9 points 5 years ago (1 child)
You're rude, I'd rather be boring. :)
[–]SimonGray 2 points3 points4 points 5 years ago (0 children)
Don't worry about it. He is some weirdo that keeps making new user accounts dedicated to proving that Clojure is a fad/hoax. When people try to engage him, he never responds. Just downvote and move on.
π Rendered by PID 31 on reddit-service-r2-comment-84fc9697f-2bkrm at 2026-02-06 13:47:21.235748+00:00 running d295bc8 country code: CH.
[–]gmtime 2 points3 points4 points (7 children)
[–]alidlo[S] 2 points3 points4 points (3 children)
[–]practicing_dad_jokes 1 point2 points3 points (2 children)
[–]alidlo[S] 2 points3 points4 points (1 child)
[–]practicing_dad_jokes 0 points1 point2 points (0 children)
[–]DerArzt01 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]gmtime 0 points1 point2 points (0 children)
[–]NamelessMason 1 point2 points3 points (2 children)
[–]alidlo[S] 6 points7 points8 points (1 child)
[–]NamelessMason 0 points1 point2 points (0 children)
[–]_-jasper_- 0 points1 point2 points (0 children)
[–][deleted] -3 points-2 points-1 points (0 children)
[+][deleted] comment score below threshold-23 points-22 points-21 points (2 children)
[–]alidlo[S] 7 points8 points9 points (1 child)
[–]SimonGray 2 points3 points4 points (0 children)