Re: [Flashcoders] AS3 Coding Conventions Question

2008-03-17 Thread eric e. dolecki
Well, you're only going to use the FOO_BAR, so I don't think it really
matters. Instead of a string, you could use a number and just have it be 1,
etc. as well.

On Mon, Mar 17, 2008 at 12:05 AM, Jason Van Cleave [EMAIL PROTECTED]
wrote:

 This is a pretty nice doc and I agree/use most of these while doing as3
 development. The use of ALL_CAPS constants makes sense to me but I am not
 understanding what the purpose would be to not make the variable be the
 same
 as the value.

 For instance, this is what Adobe says and does from:

 http://opensource.adobe.com/wiki/display/flexsdk/Coding+Conventions

 --
 Constant names

 Use all uppercase letters with underscores between words: OFF,
 DEFAULT_WIDTH
 .

 The words in the identifier must match the words in the constant value if
 it
 is a String:

 public static const FOO_BAR:String = fooBar;

 --

 For me it makes more sense and helps consistency to make it:

 public static const FOO_BAR:String = FOO_BAR;


 Anyone have a defense to Adobe's position?
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 Coding Conventions Question

2008-03-17 Thread Ian Thomas
On Mon, Mar 17, 2008 at 8:27 AM, eric e. dolecki [EMAIL PROTECTED] wrote:
 Well, you're only going to use the FOO_BAR, so I don't think it really
  matters. Instead of a string, you could use a number and just have it be 1,
  etc. as well.
Except having it as a meaningful string makes it much easier to trace
when debugging. :-)

As for Jason's question - I can't see a particular reason for it to be
lowercase rather than upper. I guess it's just the convention in
Adobe's existing codebase.

Ian
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS3 Coding Conventions Question

2008-03-17 Thread Muzak

Maybe it's because alot (most?) static constants refer to an event type:

Event.CHANGE - change
Event.CLICK - click
REMOVED_FROM_STAGE - removedFromStage

I've noticed that in Flex, if you define Event metada, and you follow those rules, you'll get automatic codehints for that event, 
even though you haven't defined any constant for that event type.


package com.muzakdeezign.sample.controls {
import mx.core.UIComponent;

[Event(name=myEvent,type=mx.events.Event)]

public class MyClass extends UIComponent {
 public function MyClass() {
 }
}
}

If you then create an instance of that class add a listener to the instance, 
MY_EVENT will show up in the codehints.

mx:Script
 ![CDATA[

  import mx.events.Event;
  import com.muzakdeezign.sample.controls.MyClass;

  private function appInit():void {
   var instance:MyClass = new MyClass();
   instance.addEventListener(Event.MY_EVENT ...
  }

 ]]
/mx:Script

Just typing Event. will show MY_EVENT as one of the event types in the codehints, even though I haven't defined that constant 
anywhere.
So I guess it picks up those constants from the metadata: [Event(name=myEvent,type=mx.events.Event)] and splits the words on 
each uppercase character and sticking an underscore in between.


Only problem is that it doesn't actually work, since there's no 
Event.MY_EVENTconstant.

regards,
Muzak

- Original Message - 
From: Jason Van Cleave [EMAIL PROTECTED]

To: Flash Coders List Flashcoders@chattyfig.figleaf.com
Sent: Monday, March 17, 2008 5:05 AM
Subject: [Flashcoders] AS3 Coding Conventions Question



This is a pretty nice doc and I agree/use most of these while doing as3
development. The use of ALL_CAPS constants makes sense to me but I am not
understanding what the purpose would be to not make the variable be the same
as the value.

For instance, this is what Adobe says and does from:

http://opensource.adobe.com/wiki/display/flexsdk/Coding+Conventions

--
Constant names

Use all uppercase letters with underscores between words: OFF, DEFAULT_WIDTH
.

The words in the identifier must match the words in the constant value if it
is a String:

public static const FOO_BAR:String = fooBar;

--

For me it makes more sense and helps consistency to make it:

public static const FOO_BAR:String = FOO_BAR;


Anyone have a defense to Adobe's position?


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] AS3 Coding Conventions Question

2008-03-17 Thread Merrill, Jason
public static const FILEUPDATED:String = fileUpdated;

With that convention, I always thought perahaps so there were no value
conflicts, if there happened to be one somehow - by naming it the same
as the constant name, you pretty much ensure that, and the lower case
was just to distinguish it from the constant itself - it could be the
significant number 42 for that matter.  

Jason Merrill
Bank of America  
GTO LLD Solutions Design  Development 
eTools  Multimedia 

Bank of America Flash Platform Developer Community


Are you a Bank of America associate interested in innovative learning
ideas and technologies? 
Check out our internal  GTO Innovative Learning Blog  subscribe.




 

-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of Muzak
Sent: Monday, March 17, 2008 10:12 AM
To: Flash Coders List
Subject: Re: [Flashcoders] AS3 Coding Conventions Question

Maybe it's because alot (most?) static constants refer to an 
event type:

Event.CHANGE - change
Event.CLICK - click
REMOVED_FROM_STAGE - removedFromStage

I've noticed that in Flex, if you define Event metada, and 
you follow those rules, you'll get automatic codehints for 
that event, even though you haven't defined any constant for 
that event type.

package com.muzakdeezign.sample.controls {  import 
mx.core.UIComponent;

 [Event(name=myEvent,type=mx.events.Event)]

 public class MyClass extends UIComponent {
  public function MyClass() {
  }
 }
}

If you then create an instance of that class add a listener 
to the instance, MY_EVENT will show up in the codehints.

 mx:Script
  ![CDATA[

   import mx.events.Event;
   import com.muzakdeezign.sample.controls.MyClass;

   private function appInit():void {
var instance:MyClass = new MyClass();
instance.addEventListener(Event.MY_EVENT ...
   }

  ]]
 /mx:Script

Just typing Event. will show MY_EVENT as one of the event 
types in the codehints, even though I haven't defined that 
constant anywhere.
So I guess it picks up those constants from the metadata: 
[Event(name=myEvent,type=mx.events.Event)] and splits the 
words on each uppercase character and sticking an underscore 
in between.

Only problem is that it doesn't actually work, since there's 
no Event.MY_EVENTconstant.

regards,
Muzak

- Original Message -
From: Jason Van Cleave [EMAIL PROTECTED]
To: Flash Coders List Flashcoders@chattyfig.figleaf.com
Sent: Monday, March 17, 2008 5:05 AM
Subject: [Flashcoders] AS3 Coding Conventions Question


 This is a pretty nice doc and I agree/use most of these 
while doing as3
 development. The use of ALL_CAPS constants makes sense to 
me but I am not
 understanding what the purpose would be to not make the 
variable be the same
 as the value.

 For instance, this is what Adobe says and does from:

 http://opensource.adobe.com/wiki/display/flexsdk/Coding+Conventions

 --
 Constant names

 Use all uppercase letters with underscores between words: 
OFF, DEFAULT_WIDTH
 .

 The words in the identifier must match the words in the 
constant value if it
 is a String:

 public static const FOO_BAR:String = fooBar;

 --

 For me it makes more sense and helps consistency to make it:

 public static const FOO_BAR:String = FOO_BAR;


 Anyone have a defense to Adobe's position?

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] AS3 Coding Conventions Question

2008-03-16 Thread Jason Van Cleave
This is a pretty nice doc and I agree/use most of these while doing as3
development. The use of ALL_CAPS constants makes sense to me but I am not
understanding what the purpose would be to not make the variable be the same
as the value.

For instance, this is what Adobe says and does from:

http://opensource.adobe.com/wiki/display/flexsdk/Coding+Conventions

--
Constant names

Use all uppercase letters with underscores between words: OFF, DEFAULT_WIDTH
.

The words in the identifier must match the words in the constant value if it
is a String:

public static const FOO_BAR:String = fooBar;

--

For me it makes more sense and helps consistency to make it:

public static const FOO_BAR:String = FOO_BAR;


Anyone have a defense to Adobe's position?
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders