result = ???
TL;DR: Use good names always. Result is always a very bad name.
If you don't know how to name it, just name the variable with the same name as the last function call.
Don't use IDEs without automatic refactors.
var result; result = lastBlockchainBlock(); // // Many function calls addBlockAfter(result);
var lastBlockchainBlock; lastBlockchainBlock = findlastBlockchainBlock(); //... // Many function calls // we should refactor them to minimize space // between variable definition and usage addBlockAfter(lastBlockchainBlock);
We must forbid the word result to be a variable name.
Result is an example of generic and meaningless names.
Refactoring is cheap and safe.
Always leave the campground cleaner than you found it.
When you find a mess on the ground, clean it, doesn’t matter who did it. Your job is to always leave the ground cleaner for the next campers.
Code Smell 79 - TheResult
Maxi Contieri ⭐⭐⭐ ・ Jun 14 '21 ・ 1 min read
Code is like humor. When you have to explain it, it’s bad.
Software Engineering Great Quotes
Maxi Contieri ⭐⭐⭐ ・ Dec 28 '20 ・ 13 min read
This article is part of the CodeSmell Series.
Top comments (6)
Thank you very much for your possitive feedback.
You are absolutly right.
I try to write code smells in many different languages to be language agnostic.
In this case, I chose JS (which I don't master as you see)
I made some mistakes.
Now, with your advice, I've corrected them.
Thank you very much!
Cool, keep up the good work! I'll delete my comment.
There's no need. Thank YOU Tim!
code is about intent and with result we are sharing at the earliest the function exit value.
anyway your example is exaggerated as one could define result / res closer to function exit and also your function looks like doing too much :).
of course it is exagerated to show result problems.
even dough you define it and use it on next line you should definitively choose a better name.
Refactors are free