DEV Community

Devansh Gulhane
Devansh Gulhane

Posted on

What is your hack for coming up with variable and function names?

Top comments (5)

Collapse
 
alinp25 profile image
Alin Pisica

I like to structure my tasks in small and quick ones. When I define my variables and functions I like to make a schema / work flow of how everything should happen and try to take the keywords of subjects and represent them as variables and the verbs to be the functions. If I take one out of the context and it doesn't make sense, I need to improve it by making it more explanatory. If at least 2 of them are simmiliar I get to the conclusion that something is wrong in the previous work flow and go back to the previous step. It's time consuming, but on a long run I found it being pretty useful.

Collapse
 
hussein_cheayto profile image
hussein cheayto

Can you give an example?

Collapse
 
devagul93 profile image
Devansh Gulhane

Wow Alin, that's very systematic, I am going to try this.

Collapse
 
avalander profile image
Avalander • Edited

When I can't come up with a good name for a function, I just call it kevin. Usually, after working a bit more on the code and using the function I have a clearer idea of the purpose of the function and I can come up with a better name.

Either that or a colleague suggests a better name in the code review.

Collapse
 
devagul93 profile image
Devansh Gulhane

Hi Neil, Thanks a lot.
Checking out the book