Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Dale Matthews   on Jul 04 In Java Category.

  
Question Answered By: Mark R   on Jul 04

Although I did not write this book (I wish I
did), you might check out Steve McConnell's Code
Complete. While the coding conventions in that book are for C/C++
they are applicable to Java and the concepts are
applicable to all development. Naming and Coding
Conventions are about as varried as there are programmers.
What I like is not what my bosses like, so I follow
their coding conventions. I like the Hungarian
nomenclature described in Code Complete, but not many people I
know follow it and it confuses people who
don't. A few guidelines, however: 1) Don't abreviate...
Java will take names as long as you want, so make your
names as descriptive and uncryptic as possible. 2)
Class Names Always begin with a Capital letter and each
new word in the name begins with a capital. The name
should be descriptive of what the class is. If it is a
domain class (representing business objects) it should
be made of nouns. ie. PayrollAccount If
it is a "helper" class, it should be
verbs. ie ReconcileCheckbookHelper Utility classes should follow
the
same: CollectionFactory 3) Your objects could actually be
descriptive... PayrollAccount payrollAccount = new
PayrollAccount(); If
you are using a collection Vector
payrollAccounts = new Vector(); Use plural.... 4)
Different people use different techniques to differentiate
between local and instance varables. First, your
methods should not be so large that you can't see the
whole thing in one glance. When you define local
variables in your method, you can then see that you can
easally see that you have defined it within your method.
This will help if determining if you have a local or a
class (instance variable/object). The
objects/variables always begin in a lower case. You can go
on and on... but these are just a few conventions
for starters. Check out Code Complete; and that will
help you on your way further.

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Naming conventions Or get search suggestion and latest updates.


Tagged: