- Try to minimize the scope of local variables. It's not necessary to declare them at the beginning of the method, declare them where they are first used.
See Effective Java, Second Edition, Item 45: Minimize the scope of local variables. (Google for "minimize the scope of local variables", it's on Google Books too.))
The
m_
prefix is unnecessary and uncommon in the Java world. See Effective Java, 2nd edition, Item 56: Adhere to generally accepted naming conventionsThe
sendMail
method should validate its input parameters. Does it make sense if theform
,to
etc. isnull
or empty string? If not, check it and throw aNullPointerException
or anIllegalArgumentException
. (Effective Java, Second Edition, Item 38: Check parameters for validity)