Sign in to follow this  

Name convention. What do you prefer, jlabelUsername or usernameJLabel?

This topic is 2660 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi mates!

I'm developing and app in eclipse and java, using SWING for create its user interface.
My question is, what name convention do you prefer for your visual components and what is the reason, jlabelUsername or usernameJLabel?

Thanks for your opinion!

Share this post


Link to post
Share on other sites
I'd drop the J prefix letter; no point in informing reader that the label is of Swing type, because 1) he can likely see it in his IDE anyway, 2) you won't most likely ever be using labels of another GUI type in the same class as the Swing code.

As for labelUsername vs usernameLabel I find the latter more natural, although the former can look more structured in an alphabetic ordering of variables. However, if you have so many variables in a class that strict alphabetic ordering is necessary to navigate it, it can be argued the class is way too big. E.g. it may be possible to create sub classes out of logical sub-elements that extend classes such as JPanel:s instead which the window then uses.

Share this post


Link to post
Share on other sites
Quote:
Original post by Derakon
I'd go with usernameLabel instead of labelUsername, but I don't have a strongly-articulated reason for doing so. It just feels more natural to me.


I disagree. While this mostly comes down to personal taste, I find that when you're doing UI programming it helps to be able to quickly look up a control based on its type (since many IDEs like to sort things alphabetically). I maintain a lot of UI code at work, and since I've written about 2% of it, it really helps when things are easy to find.

EDIT: And please, don't worry so much about what people prefer. Write what works for you. :)

Share this post


Link to post
Share on other sites

This topic is 2660 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this