12
25 Comments

A tool to choose variable and function names

Hi all!

I'm building a tool to help programmers choose appropriate variable and function names.

Why?

I can't stand poor variable names and I know I'm not alone in this. I've looked for existing solutions but nothing really stands out.

Right now my current process consists of:

  • starting with a - usually generic - word
  • using a thesaurus to look up synonyms
  • going through progressive refinement until coming up with a suitable name.

Any comments or ideas are really welcome!

  1. 5

    I always find naming a struggle but I never thought of looking for a product beyond a thesaurus to solve it for me.

    Now that I read your post though, I imagine if what you're building was even just a thesaurus but built into the IDE as a plugin, it'd save me a bit of time because I wouldn't need to open my browser to find synonyms.

    Having said that, I personally have trouble imagining myself paying for a tool that helps me name variables/methods. This may be only me.

    1. 1

      Hi Matt, thanks for your feedback - really appreciated. I totally agree with you that a plugin would be great and that monetization would be quite challenging - off the top of my head I can only think of ads, and I hate them.

      1. 1

        Hmm yeah ads inside the IDE sound quite disturbing haha

  2. 3

    So, this is definitely a minor point of friction for many devs. The key word there is "minor". That doesn't mean people wouldn't use a tool to help fix the issue, but it would have to be effortless to use. Why would I open my browser and load your web-app instead of just clicking on my Merriam-Webster bookmark?

    In this context, I think effortless means integrating with popular IDEs. Otherwise, this is a problem that was solved two thousand years ago by the thesaurus.

    1. 1

      Hi Griffin, thanks a lot for taking the time to comment.
      I'm looking at this from another perspective: why would you ever bookmark Merriam-Webster, if a "thesaurus for function names" existed?
      I totally agree with you that this can be seen as an inconvenience rather than a problem for developers, so the tool should be frictionless
      (lightweight, no account needed and so on).

      1. 1

        If you could create sufficient value above what a normal thesaurus provides than you've got something! I'm curious about how you plan to do this. Are you going to try and come up with suggestions for a list of common functions or categories of function?

  3. 2

    Some would say you're solving one of the hardest problems in computer science 😄 good luck with it!

  4. 2

    I too struggle sometimes with naming a variable, and having an IDE In my plugin to help me out would be a good nice-to-have.

    1. 1

      Hi! So is having a plugin for your IDE instead of going to a website a deal-breaker for you?

      1. 1

        I was also about to say that an IDE plugin would be probably a better approach.

  5. 1

    hey! thanks for the follow on IH! appreciate that.

    i don't struggle with this, btw... i dunno. i just use simple terms.

  6. 1

    This sounds like a nice idea, I am a bit worried of how well it can actually work. How would the tool know what the variable should be named? The name should fit within the code style of the company, be short enough, be descriptive within this context, be unique, be easy to type and many other variables.

    The short question is, how could the tool know better than me what variable name would be suited? Will it analyze the AST of the code and use AI to generate a relevant name based on the context and what the variable stores? If not, will it just be an autocomplete for English words?

  7. 1

    That sounds super interesting. I would love to hear when it gets released. Also, since I am a JetBrains IDE user, I would appreciate some kind of plugin for these IDEs. Good luck!

    1. 1

      I'll try to build it in public, so definitely posting on IndieHackers about it!

  8. 1

    I've been developing software for almost 10 years now, 4 of those professionally. I personally don't think this is a big enough problem to have a standalone tool for (especially a paid one).

    I've had instances in the past where I had a hard time coming up with variable/function names but it didn't nearly cause enough friction to look for tools or even use a thesaurus. Just my two cents, good luck!

    1. 1

      Your two cents are very much welcome!

  9. 1

    The arguments are many with the style of, some prefer expressive some make abbriviations, than you need to know specific project abbriviations...

    Function naming I think is intersting if one can get to an AI level naming for short functions, coupled with auto refactoring, it can be a really nice thing..

    due IDK if I'd pay for such a service, product.. I might try to use something like that.

    I'm much into the solve it for me over offer options, can you figure a name out of context, like often using a version of the resulting class name as a name for a temporary local variable..

    Also if context can be used for consitency of naming, like the project style or as you mentioned api, some forms from other fuction names... like if you use plural or single, if it connects to another term already expressed elsewhere..
    Also can probably gather data from other project for words that are commonly used, like 'users' would be a common term for table names, api, classes... words that are used "in the industry" are better than original ones for most cases.

    1. 1

      Hi, thanks a lot for your ideas! I agree 100% with the "industry standard" argument - this is should be one of the benefits over a standard thesaurus.

  10. 1

    This is a cool idea Marcop. New devs & sometimes more experienced devs tend to struggle with this. So will it be an extension for code editors or a stand alone app?

    1. 1

      Hi Dilpreet! I'm starting with a web app. The bulk of the work has been building the keyword recommendation model - I'll worry about editor extensions later on if there's enough interest.

      1. 1

        If I were you, I would perhaps start the same way because building a recommendation model sounds more exciting than an IDE extension and I'm also more familiar with building web apps than extensions, BUT, now looking from the point of view of a complete outsider these 2 ideas come to my mind:

        • Building a good recommendation model is perhaps quite sophisticated and time-consuming. Once the model is ready as a web app, it may be quite difficult to differentiate it from a general thesaurus until it becomes pretty mature and good.

        • A super simplified plugin that just brings generic thesaurus recommendations to an IDE may not ever bring in any money, but it MAY get some traction to justify spending more time to evolve the recommendation model into something more sophisticated.

        Just ideas. I may be quite wrong :)

  11. 1

    That is a cool idea, I sometimes struggle with finding appropriate names!

  12. 1

    This comment was deleted 3 years ago.

  13. 9

    This comment was deleted a year ago.

    1. 1

      Hi Primer, thanks for your feedback!

      I'm not talking about just choosing a name, but choosing the best one - where "best" can be defined as the most descriptive or specific, the easiest to understand and so on.
      I often find myself spending lots of time coming up with it, especially for public APIs that can be difficult to change after release: a tool that can suggest different options will save me quite a bit of time, that's why I'm building it.

      The best example and use case I can think of is described in a post by DHH: https://m.signalvnoise.com/hunting-for-great-names-in-programming/

      1. 3

        Wow. Must have been a slow week for blog material.

      2. 1

        This comment was deleted a year ago.

Trending on Indie Hackers
How I grew a side project to 100k Unique Visitors in 7 days with 0 audience 49 comments Competing with Product Hunt: a month later 33 comments Why do you hate marketing? 29 comments My Top 20 Free Tools That I Use Everyday as an Indie Hacker 18 comments $15k revenues in <4 months as a solopreneur 14 comments Use Your Product 13 comments