| Author |
What's wrong with assigning the file descriptor to a class called Names?
|
Armando Moncada
Ranch Hand
Joined: Nov 14, 2011
Posts: 30
|
|
What's wrong with assigning the file descriptor to a class called Names?
See line 24
|
Armando
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
Well, actually, in that code you're trying to assign it to a variable called Names, not a class.
But what makes you think there is something wrong with it?
|
 |
Armando Moncada
Ranch Hand
Joined: Nov 14, 2011
Posts: 30
|
|
|
Well, my nitpicker said, "you're assigning the file descriptor to a class called Names? That can't be right."
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56191
|
|
|
However, naming conventions dictate that variables should begin with a lowercase character. But it's just a convention (though not following it makes code surprisingly hard to read).
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24057
|
|
What Bear said!
Check this out:
You see how similar these two lines are? As a trained Java programmer, because of the capitalization I immediately think these are both static method calls, one on a class named "Names", and one on a class named "Collections". The fact that there is a class named "Names", and it doesn't actually have a method named "close()" is a source of great cognitive dissonance. It's a time waster, now, because I have to figure out what the heck is going on. If the variable name started with a lower-case letter, then I'd know it was a variable, and I'd first find out what type it was before trying to find any information about close().
|
[Jess in Action][AskingGoodQuestions]
|
 |
Mike Simmons
Ranch Hand
Joined: Mar 05, 2008
Posts: 2782
|
|
|
Also, you're using the name "Names" twice, for two completely different things. One is the static class Names, and the other is for a local variable of type TextFileIn. This would be very confusing even if you weren't violating the name convention that Bear and Ernest are talking about. You should have different names for different things.
|
 |
 |
|
|
subject: What's wrong with assigning the file descriptor to a class called Names?
|
|
|