incubator-flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carol Frampton <cfram...@adobe.com>
Subject Re: [Proposal] Add PostCodeValidator and PostCodeFormatter to the SDK
Date Tue, 13 Mar 2012 14:07:32 GMT
Ok, just looked it up.  I was wrong.

If the various branches of an if/else statement involve single statements,
don't make them into blocks.

But if any branch has multiple statements, make all of them into blocks.

ref: 
http://opensource.adobe.com/wiki/display/flexsdk/Coding+Conventions#CodingC
onventions-ifstatements
(doesn't seem to be finding if statement section so search for "If the
various branches of an if/else")

Carol




On 3/12/12 5 :13PM, "Justin Mclean" <justin@classsoftware.com> wrote:

>HI,
>
>> One more clarification.  If there is an else it should then be
>> 
>>    if (expresion)
>>    {
>> 	statement;
>>    }
>>    else
>>    {
>> 	statement;
>>    }
>
>Even for single line statements?
>
>I've seen quite a lot of missing braces in if/elses when there only one
>line. I've also seen braces for single line if statements  in the
>existing code base.
>
>Picking a file I've look at recently (Validator.as) it contains code like
>this. 
> if (!suppressEvents)
> {
>     dispatchEvent(resultEvent);
> }
>
> if (obj == null)
> {
>     //return true;
> }
>
> if (_trigger)
>     return _trigger;
>        
>  else if (_source)
>      return _source as IEventDispatcher;
>
>
>I particularly like the second example :-) I guess it possible that the
>braces were added after the return true was commented out so not to have
>the condition effect the line below. The blank line in the 3rd example
>certainly doesn't help comprehension of the code.
>
>Justin
>
>


Mime
View raw message