• 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

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: 13089
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.
 
Marshal
Posts: 28261
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
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 = ...
 
Something must be done about this. Let's start by reading this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic