You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Geir Magnusson Jr." <ge...@optonline.net> on 2001/12/28 15:33:11 UTC

Re: cvs commit: jakarta-commons/beanutils/src/java/org/apache/commons/beanutils BasicDynaBean.java BasicDynaClass.java DynaProperty.java DynaBean.java DynaClass.java

On 12/28/01 9:05 AM, "Erik Hatcher" <ja...@ehatchersolutions.com>
wrote:

> A question about coding standards...
> 
> ----- Original Message -----
> From: <cr...@apache.org>
> 
>>           if (!values.containsKey(name))
>>               throw new IllegalArgumentException
>>                   ("No property " + name + " exists");
> 
> I'm in the camp that believes curly brackets should surround even single
> statement code blocks.  Is this mentioned in the Sun coding standards?
> 
> Granted, Struts works very well, but ActionServlet drives me crazy to read
> through!  :)  (no offense, Craig)
> 
> But more importantly, why the inconsistency?
> 
>>           try {
>>               return ((DynaBean)
> constructor.newInstance(constructorValues));
>>           } catch (InvocationTargetException e) {
>>               throw new InstantiationException
>>                   (e.getTargetException().getMessage());
>>           }
> 
> Curly brackets are used for try/catch, but not for if.
> 
> I'd like to push for always using curly brackets, but those might be
> fighting words for some.... so ignore little ol' me if its a big deal as I
> don't want to get a long thread started about such things, I just wanted to
> bring it up and see if this particular issue is specified in the Jakarta
> (aka Sun) coding standards.  I'm a follower (as best I humanly can) of the
> guidelines in the book The Elements of Java Style.
> 
>   Erik
> 

I know this will turn into a firefight, so I will toss my grenade and run,
but I agree with you - brackets for single statements in an if() block make
things so much easier to read, and help prevent unintentional bugs when
someone adds another statement and forgets to add the braces...


-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"He who throws mud only loses ground." - Fat Albert


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>