• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Is this bad form?

 
Ranch Hand
Posts: 57
IntelliJ IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm completing an assignment for class which will involve a JFrame with multiple buttons, textfields, etc. Is it acceptable naming convention to name the objects btnHelp (for the help button), txtInput(for the textfield where text is displayed)? I believe this is referred to as the Hungarian notation. Even if it's not, I remember this being the convention for VB 5, and I thought it was easy to identify what sort of component you were dealing with in the code. However, I recall my instructor grumbling about "not being Hungarian" or something, so if it's considered bad coding I would like to know. So, is this one of the accepted naming conventions or not?

Thanks,

Brandt
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm sure people will argue this one for days. however, according to the JavaRanch style guide, it should not be used.
 
Sheriff
Posts: 28401
100
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
Guides or no guides, you almost never see it used in Java code in the wild. Pick any open-source project at random and download its source code, I will bet long odds that it does not use Hungarian notation. If "acceptable" means "what everybody does", that should take care of "acceptable".
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you work for Microsoft, it's an accepted convention. If you work for almost anyone else, it's frowned upon.
 
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
But you'll very often see

JButton helpButton = ...
 
reply
    Bookmark Topic Watch Topic
  • New Topic