• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
 
Marshal
Posts: 28226
95
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: 67747
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: 24207
46
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().
 
Master Rancher
Posts: 4830
74
  • 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