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()

Variables: isNextToBlockedSquares;

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

closed as primarily opinion-based by durron597, user40980, Bart van Ingen Schenau, Kilian Foth, user22815 Jul 27 '15 at 16:10

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.


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 =) – Bryan Harrington Nov 20 '10 at 6:04
  • @Bryan: You're welcome. :) – Adam Lear Nov 20 '10 at 6:05

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.

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