Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

For blackberry GUI developement. I am using the name convention like backButtonField and some of my colleagues are using btnBack.

But sometimes I stuck with the names like loginVerticalFieldManager its a very long name. At that time vfmLogin looks better

So for GUI components names what convention should I follow?

share|improve this question

7 Answers 7

up vote 7 down vote accepted

I would say use btnBack instead of backButtonField. Even I at the other side of the world recognize that type of notation.

Update: However there is no right or wrong as long as all members in the team agree to write the same notation.

share|improve this answer
    
actually i have seen this geosoft.no/development/javastyle.html 18. JFC (Java Swing) variables should be suffixed by the element type. and started to follow the convention. –  Vivart Nov 19 '10 at 13:09

not being familiar with Blackberry stuff this may be completely unsuitable, but I tend to just use a name, as the type system will tell you what it actually is.

Button back;
Button forward; 

Controversial I know.

share|improve this answer

Never, ever be afraid of long names. Other than for visual controls (where I still rather archaically use three letter prefixes of the btn variety to avoid confusion between the controls and the fields that back them) I never use abbreviations and try to make all my names as useful as possible - if that means they're long then so be it. With copy & paste and code complete it's not like I ever type them again anyway :-)

share|improve this answer

Hungarian was good when we didn't have IDEs and plugins for the IDEs that would let us find what we were looking for other than by cruising through a drop down list that might, if you were lucky, be alphabetized. With VS2008 or 2010 and resharper, I'm 2 or 3 keystrokes from a search dialog to let me type in "Button" and finding BackButton, OkButton, CancelButton far more quickly than hunting through a drop down.

In general, I've gotten tired of goofy naming conventions. If I wrote a manual on how to use my software I would direct my user to use the "Back button", therefore it's fairly intuitive to name the object BackButton. Your vocabulary remains the same when your talking to a Business Analyst as when you're talking to another programmer and I can't see anything wrong in that.

The other problem with any sort of abbreviation as a prefix that isn't super intuitive is that in an OO world, it quickly falls flat on it's face and everything ends up being obj or ctrl (for the UI components). I really can't find much use in that. Those drop down lists (esp the VS drop downs that only do 1 character for type ahead) become a pain in that case. When there's 3 btns on a list, hey, that's easy. When there's 20 ctrls on that list, you're back at square one.

share|improve this answer

Try to imagine whether someone else will be able to figure out what the variable is for based on the name. backButton and btnBack can probably be deduced, but vfmLogin is pretty cryptic. I try to avoid acronyms for variable names. Something more clear is usually just a few more keystrokes, and it will usually be much more readable.

share|improve this answer

The reason I stll use this bastardized variation of Hungarian Notation in my GUI code is simply because Visual Studio has a convenient dropdown list of controls in the code page. They are listed alphabetically, and when looking to code an event handler for a Button, I can scroll to the "btn" section and find the one I want easily. Even if I don't remember it's exact name, I'll remember it when I see it. Otherwise, I'd have to hunt through the whole list tyring to remember the button's name, or go find it on the form.

share|improve this answer

Avoid non-standard abbreviations.

Button -> btn is arguably ok (some people will disagree with that).
VerticalFieldManager -> vfm is definitely not (I thought it was was Visual Form or something).

(WTF is a Vertical Field Manager anyway - possibly sounds like a stupid way of saying "Column"?)


Definitely the element type should be a suffix, not a prefix.

So BackButton (or BackBtn) and so on.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.