> If I need something like pi as a const I would declare a class member
const for pi, not a function scoped const var.
 
If you needed to use this constant in only one method, declaring it as a
class member would be a tiny bit wasteful, as it would always sit there
taking up memory, whereas a local const wouldn't.

> why dont we see widespread use of this style within Adobe code
 
It wasn't part of our AS3 coding guidelines, but one of our engineers
really favors it. In hindsight, we should probably be using it
everywhere that a local doesn't change after declaration, as this can
give a future version of the compiler useful info to help optimization.
 
Gordon Smith
Adobe Flex SDK Team

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of reflexactions
Sent: Thursday, December 20, 2007 7:21 AM
To: [email protected]
Subject: [flexcoders] Re: const?



I work in a team and have so done for the last 20+ years and never 
yet declared a variable with function level scope as const just to 
prevent some other person coming along later and changing the code 
value of the variable if they think it is needed.

...and if thats was the case why dont we see widespread use of this 
style within Adobe code...

If I need something like pi as a const I would declare a class member 
const for pi, not a function scoped const var.

But seems you guys program different from the way we do I guess,

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "johantrax" <[EMAIL PROTECTED]> 
wrote:
>
> > unless you have a split personality.
> 
> Well... it might be you just provided the answer there. When working
> on a project having the size of Flex, you work in a team.
> Most probably a short function is indeed written by one person. But
> what guarantees that nobody else will one day pass by and alter your
> functions? In the case of shared work, defining that variable as a
> const is a much quicker way of telling others that it's a
> marker/whatever, than having to put comment out there, saying:
> //next is a variable
> //I pray to you and the lord to not change it
> // because it just holds some value I need to remember
> var pleaseDoNotChangeMe:Number = 3.1415...;
> // End of Prayer ;)
> 
> --Johan
>



 

Reply via email to