Meaningless Drivel is fun!*
The moose likes Cattle Drive and the fly likes What is the benefit of the num prefix? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "What is the benefit of the num prefix?" Watch "What is the benefit of the num prefix?" New topic
Author

What is the benefit of the num prefix?

Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1344
    
  12
In a lot of the assignemnts I've been nitpicking lately, I've seen variable names prefixed with <code>num</code>.

I'm curious as to what benefit people see to using this prefix?

I'm not necessarily asking only those who actually use it. Also, I'd like to hear arguments both for and against the use of such a prefix.

Also note that I'm not in Nitpick mode - I'm trying to figure out what I might be missing here.
Dick Summerfield
Ranch Hand

Joined: Oct 04, 2007
Posts: 90
How come noboby is answering? Surely those who have used this prefix chose it for some reason... ?
I thought I had never used it but I see I have - in a program working with some numbers which are purely that. They do not represent an amount of anything. In this case, surely it's reasonable to call them num1, num2 etc.? I have to admit that later I called them number1 and number2 (I remembered a tip from a nitpicker:- letters for identifiers come free in Java so why abbreviate?).
Anymore "num" users?
Evan Reisman
Greenhorn

Joined: Oct 25, 2007
Posts: 2
I think num is short for "numb," as in what happens to our brains during the holidays festivities.

On a more serious side (which is almost impossible with me), my feeling is that it is easier for people to think of a variable name as a string rather than a token or identifier (which is really what it is). So this is easier:

String seven = "seven";

rather than this:

int seven = 7;

So people have a tendency to do this:

int numSeven = 7;
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1344
    
  12
Dick, there are most definitely other <code>num</code> users out there.

Evan, that sounds like a reasonable explanation. In those terms, it seems like a variation on hungarian notation, which I'm not particularly familiar with.
Belinda Lawson
Greenhorn

Joined: Feb 10, 2007
Posts: 10
Originally posted by Katrina Owen:
In a lot of the assignemnts I've been nitpicking lately, I've seen variable names prefixed with <code>num</code>.

I'm curious as to what benefit people see to using this prefix?


Wow, I just realized that I sort of did this and didn't even think about it.
Let me see if I can lasso a reason by the horns.

In my most recent attempt, I used a variable named <code>numberOfFullLines</code> to denote, well, the number of lines that were fully populated by elements, as opposed to ones that were only partially populated. I guess an equally good name might have been simply <code>fullLines</code> or <code>fullyPopulatedLines</code> or <code>completeLines</code>.

This is an interesting question, since I have always felt that I am absolutely terrible at giving variables meaningful names. But by convention, I think counters that end in in the word <code>count</code> make sense. And maybe also limits that begin with <code>max</code>.

What's rather curious is that, just now, I realized that I would be inclined to completely spell out <code>number</code> in a varible, but use <code>max</code> as an abbreviation for maximum. Guess I'll nitpick myself for being inconsistent.

One thing that makes my head spin with regard to java naming is classes that end in the suffix <code>Impl</code>. I know that's short for implementation, but couldn't someone have picked a better convention? I see that all the time. Why not call the interface <code>somethingInterface</code> instead of calling the implementation <code>somethingImpl</code>? Who comes up with this stuff anyhow?

Ah well, maybe I'll hang out here enough and find out that there's nothing wrong with that after all, and it's just one of those pesky personal preferences...
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1344
    
  12
Well, I would also spell out <code>number</code> and abbreviate <code>max</code>. This is consistent with how I use the English language. I will often just say "max" rather than the full "maximum" when talking about limits.

I never, however, say "num" unless it is in the sense that Evan was talking about, "numb"
Jinny Morris
Ranch Hand

Joined: Apr 29, 2007
Posts: 101
Uh ... yeah! On the other hand, I've been nitpicked for both "num" and "max" ...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is the benefit of the num prefix?
 
Similar Threads
intValue( ) doesn't work...
Assignment Java-3 (Leap)
Find errors
How to get the output like 12.00?
SOAP-ENC:Array instance validation