So I was currently in the middle of coding, unfortunately for me, I was in "The Zone" then I thought to myself, are my method/variable names to long?

POP out of the Zone I go!

So I came here to ask, are my method/variable names too long? You be the Judge! Bonus points to anyone who can figure out what I'm writing, although I'm sure a guru will figure it out fast!

Anyway, here are some of my method and variable names.

Methods :

  • searchBlockedListForBlockedSquares(),
  • isCurrentSquareNextToAtLeastOneBlockedSquare(),
  • searchBlockedListForBlockedSquares()


  • isNextToBlockedSquares

I guess there was only one variable that seemed too long.


3 Answers 3


Your names seem okay to me in terms of length. However, the way they are named suggests that maybe some new classes are in order?

For example, instead of searchBlockedListForBlockedSquares() you could have blockedList.getBlockedSquares(). Similarly, isCurrentSquareNextToAtLeastOneBlockedSquare() becomes currentSquare.isAdjacentToABlockedSquare().

  • Adjacent was the word I was looking for! Thank you =)
    – Nayrb
    Nov 20, 2010 at 6:04
  • @Bryan: You're welcome. :)
    – Adam Lear
    Nov 20, 2010 at 6:05
  • 3
    .hasBlockedNeighbor() seems nicer. Mar 7, 2020 at 14:13

I believe in descriptive variable names even if that means long variable names. And with intellisense getting more popular, I don't believe it affects much in terms of productivity.

I hate abbreviations because they are nearly impossible to consistently use. Plus, they can be ambiguous and they do make things more difficult to read. Even when they are part of a standard, I don't like them. Plus, when it comes down to it, they don't remove that many letters unless you abbreviate a lot. And abbreviating a lot kills readability.

The biggest problem long names introduces though is how long lines of code can become. Calling a function with a long name and passing it two or three long variable names can make for one long line of code. Because of that, I do try to keep my names as short as possible though again, I'd rather have descriptive names even if it means wrapping lines or scrolling.

Looking at your example names though, the fact that all end with BlockedSquares makes me think that part of the name might be redundant. In fact, it might also mean that these items can be encapsulated into their own class, probably named BlockedSquares. That change that makes the names quite a bit shorter.


A variable name is the wrong length when it is not clearly describing it's purpose. That applies to being too short or too long.

Short and terse variable names can be ambiguous, or worse have no relationship to what the variable is. In the days of interpreted BASIC, we were limited by the interpreter to two character names. It was very difficult to come up with meaningful names in a large program. Single letter variable names are often used for for-loops and counters, but I think they should be avoided otherwise. for (i = 0; i < 10; i++) {...} uses i and that's pretty common. j is a secondary variable name.

Long variable names are too long when they become long-winded or full of empty words, making them longer than necessary. If I have a bunch of similarly named variables I'll try to remove the common parts that are dispensable and keep the uniquely identifying parts of the names.

I'd have named "isCurrentSquareNextToAtLeastOneBlockedSquare" to currentSquareNextToBlockedSquare?, if I was doing it in Ruby.

  • 1
    We can solve any naming problem by introducing more words into the name, except the problem of names with too many words!
    – Steve
    Mar 7, 2020 at 10:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.