• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

What's wrong with assigning the file descriptor to a class called Names?

 
Ranch Hand
Posts: 30
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's wrong with assigning the file descriptor to a class called Names?
See line 24
 
Sheriff
Posts: 27452
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 30
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, my nitpicker said, "you're assigning the file descriptor to a class called Names? That can't be right."
 
Sheriff
Posts: 67682
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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().
 
Rancher
Posts: 4327
59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic