| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
rather be programming
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
|
What are your standard coding practices for variables? How would you do this:
ActionScript Code:
Do you save the underscore to private only? I seen senocular go back and forth between the 2 conventions. PROTECTED UNDERSCORED So what is your way or the "standard" way?
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman |
|
|
|
|
|
#2 |
|
dondeEstanMisPantalones?
|
I think this is really preference... underscores are certainly not necessary anywhere.
I do use them for both private and protected- 99% of the time my member properties are protected as opposed to private, so my differentiation is public vs. non-public for all intents and purposes. |
|
|
|
|
|
|
|
|
#3 |
|
rather be programming
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
|
yea, I know there has been several threads on coding style, but i didn't see anything speficly about stuff like conts, protected vs private.
I know assertainfailure tends to use underscore only for private, so I just looking for some other people's inputs. And I've seen senocular go back and forth between them. I tend to use underscore for them both as well, but I picked that up from a Colin Mook book I believe. Thanks for responding! ![]()
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman |
|
|
|
|
|
#4 |
|
as[org].addListener(this)
Join Date: Dec 2005
Location: LA, California
Posts: 838
|
You know....i am more inclined to think of protected as public rather than private. If you closed off your class to modification, devs can still see the protected properties via subclassing as if they had been exposed publicly.
My conventions are a bit more extreme, however..... Generally speaking, I don't even use underscores for private properties. The only exception are private properties that are associated with getters/setters. |
|
|
|
|
|
#5 |
|
Flash Sucks
|
These habits I have picked up, and I stick to ... some actually because of Noobblack, even though I was arguing with him about it ...
It seems like most of the time I have read-only properties, but if a class is planned to be extended it will have its protected properties. Either way anything that is exposed I try to keep short and just letters (no underscores). I do use underscores though when I have read-only properties ... like ActionScript Code:
Usually it seems like read-only properties aren't set in too many places, especially if they are objects. And the underscores make distinguishing where you set them easier(?), but I'm not arguing it ... everyone has there style. For parameters I try to keep in mind the rest of the api ... If for instance initializing an object with it's position I don't mind using this in the constructor, so that I can keep the parameter as just x ... ActionScript Code:
idk ...
__________________
http://www.FF0000.com http://www.specialrelativity.org/blog http://www.myspace.com/michaelxxoa Last edited by MichaelxxOA; 11-26-2007 at 06:02 AM.. |
|
|
|
|
|
#6 |
|
rather be programming
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
|
LoL...everybody does it differently. Same concepts but different ways of implementing that concept. That's good to know!
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Oct 2005
Posts: 282
|
i picked this up from my teacher... using 'in' in front of the variable in the parameter.. it's much easier to understand.
ActionScript Code:
And the this keyword is always confusing in AS2... Sometimes flash doesn't care, sometimes it does. |
|
|
|
|
|
#8 | ||
|
AS3
|
Quote:
Quote:
Trully it dosen't matter witch style you choice - just stay with it (at least to oend of current project). My style still evolving |
||
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Inheritence question | GuyFawkes | ActionScript 3.0 | 12 | 11-02-2007 05:39 PM |
| Extending a basic framework for specific needs. | Flash Gordon | Best Practices | 2 | 09-17-2007 01:13 AM |
| protected members | felipe_chs | ActionScript 2.0 | 1 | 04-24-2007 01:55 PM |
| meaning of the underscore | billingsgate | Components | 10 | 02-11-2006 05:22 PM |
| Can we start an XML tag by an underscore ? | Mathieu_BSL | ActionScript 2.0 | 3 | 04-24-2005 06:58 PM |