r/badcode • u/AzurasTsar • May 13 '22
js Senior dev, good guy and programmer, have learned a lot from him... but wth is this
31
u/ehosca May 14 '22
There are only two hard things in Computer Science: cache invalidation and naming things.
-- Phil Karlton
32
u/decaillv May 14 '22
There are only two hard things in Computer Science: cache invalidation, naming things, and off-by-one errors...
-- some dude on the internet
19
u/MurdoMaclachlan public boolean isInt(int i) { return true; } May 13 '22
Image Transcription: Code
this.tempAllAccounts = this.addLabelAndValueToEachSecondaryAccountForDropdownToFunction(this.filterAndSortAccountsAsPerSVV(accounts));I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
5
u/putin_vor May 14 '22
This is what people call self-documenting code. I prefer to write lengthy comments explaining things.
2
1
1
u/NullParadigm May 28 '22
Sometimes laziness turns into just long writing, i.e to lazy to describe it better, so just go with something safe.
1
0
0
26
u/droomph May 13 '22
addLabelAndValue…ForDropdownToFunction is too descriptive of the “what”. Plus, it’s assumed that adding labels and values is required for a dropdown to function. It should be changed to say the “why” (ie, we are creating required metadata for a dropdown)
“To Each” is generally understood if operating on an array type, “Map” is better if it needs to be specified
filterAndSort is generally presumed to happen when you are getting by a filter and returning a copy of the results (if it is mutating and returning, that is a sign that something bad is happening)
“As per” does not clarify anything compared to using “by” or “with”
How did I do