This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Is this bad form? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Is this bad form?" Watch "Is this bad form?" New topic
Author

Is this bad form?

Brandt Charles
Ranch Hand

Joined: Apr 17, 2006
Posts: 57

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


Green, green, green!
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11175
    
  16

i'm sure people will argue this one for days. however, according to the JavaRanch style guide, it should not be used.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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".
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
If you work for Microsoft, it's an accepted convention. If you work for almost anyone else, it's frowned upon.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

But you'll very often see

JButton helpButton = ...


[Jess in Action][AskingGoodQuestions]
 
Don't get me started about those stupid light bulbs.
 
subject: Is this bad form?
 
Similar Threads
Interface & Implementation Naming Pattern
Wierd Java Beans Problem
file names
what is """scanf"""" in java??????
Naming Convention