> Agree with Rudolf on point 2. Then you completely misunderstood my point. Because I said exactly the opposite. If your variable names are 10-15 words long (including prepositions) then you should document what the function does.
On Saturday, January 29, 2022 at 1:21:19 PM UTC+2 timphar...@gmail.com wrote: > Agree with Rudolf on point 2. Long meaningful variable/function names are > good. Comments become obsolete, they become detached from their code, > they're only used to explain the name of the variable once and then you're > left with something than reads > > // urn contains the userlist > fxn := rx (frn) > > Now that editors have autocomplete to make up for my meagre typing speed, > you bet your ass I'm going to have [eg from current project] a local > variable called lastTokenWasColon and a method called addWordsToParser. > Because knowing exactly what they do when I need to modify or debug saves > me so much time and trouble. (Perhaps this varies from person to person. If > my memory is poorer than yours, it has more of an upside for me than for > you.) > > And is there a better solution to the problem in point 1 than to break the > function down into lots of little functions *with meaningful names*? (If > the names (and pieces) aren't meaningful you've only technically broken it > down.) > > On Friday, January 28, 2022 at 10:12:48 AM UTC-8 Rudolf Martincsek wrote: > >> > 2) Long variable names. >> >> Where I work (not in Go), writing comments is frowned upon. That includes >> "docblock" style comments. If a function needs to be documented, it means >> the implementation is too complex and must be broken apart to reduce >> cyclomatic or whatever perceived complexity. Also uncle bob told us that >> functions should never be longer than 2-3 lines of code, so it should be >> enough to look at the source code to see what it does. That's the general >> sentiment in my team. >> Comments are considered sign of "un"clean code. >> >> So we use long variable and function names to make the code self >> documenting. (Hint: it doesn't) >> Points 3,4,5 have similar roots, because in dynamic languages it was a >> trend many years ago. (ie: hungarian notation) >> >> On Thursday, December 9, 2021 at 2:10:18 PM UTC+2 Amnon wrote: >> >>> 1) Long functions that go on forever and contain long lambdas and 8 >>> levels of indentation. >>> >>> 2) Long variable names. >>> >>> 3) Variable names which include the type of the variable. >>> >>> 4) Packages whose name contain the word '/pkg/' >>> >>> 5) Repos which contain the prefix go- >>> >>> 6) Code where almost every line prefixed by `_, _ =` >>> and the underscores won't go away when you wipe your screen >>> >>> >>> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/c253125b-bb18-42c8-86c0-021aacf0581an%40googlegroups.com.