On 12/28/01 9:05 AM, "Erik Hatcher" <[EMAIL PROTECTED]>
wrote:

> A question about coding standards...
> 
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> 
>>           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.                                     [EMAIL PROTECTED]
System and Software Consulting
"He who throws mud only loses ground." - Fat Albert


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to