Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Coding Style

 
Keith Jones
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I'm very prone to using very long variable names and verbose class names and function names. See even the previous sentence is needlessly long. Do you think that this is a bad thing from the point of view of the SCJD exam?
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, they say that good code comments itself.

Good variable names are better than bad variable names, and in my opinion, a long one is better than one that has all sorts of vowels and consonants stripped out of it. Whenever I do consulting, I'm always reminding developers that writing Java isn't an epispode of Wheel of Fortune - you don't have to spin for a letter, and you don't have to buy a vowel.

What impact will the variable names have on the long-term maintainability of your program, and how will other developers feel about maintaining code with those names. That is really the answer to your question.

Cheers!

-Cameron McKenzie
 
Sam Codean
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i follow double standards in this case
For Swing i still prefer to have a three character prefix indicating the type of that instance like you have a Label and a Combo for Hotel NAmes
i would name them
lblHotelNames
cmbHotelNames this helps me understand the code better.
 
Chulwoo Choi
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the "Code Conventions for the Java Programming Language" by Sun:

http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html

Chulwoo
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic