I wouldn't even go so far as to say he's 99% right.  More like 33.3%.

Private properties with Public getters and setters is used for one of
three reasons.

1) You need to do adjust the value of the property when set or get, such
as applying limits (max value is 100 so if you pass 150, set it to 100),
or storing the value internally as something different and returning a
modified value (internally using .5, but the API accepts 50).

2) You need to update the class when a property is set or get.

3) You need protection against dummies.


#3 is what Ron is talking about here, because if you're not doing #1 or
#2, then you don't need getters and setters.

I use public properties when appropriate. I only use getters and setters when I need to do something to the property prior to setting it (such as limits) or some kind of update to the class when the property changes.

There's such a thing as over-architecting. OOP sacrifices speed for flexibility and scalability. You shouldn't overdo it with unnecessary function calls for setting public properties. It causes code bloat and your code doesn't perform as well. I don't wrote code for the lowest common denominator. I've got work to get done.

We're Flash developers, not C++ developers. We can't bring down the operating system with a bad value. Some of these safeguards are in place because lower-level languages can cause real damage. The only thing that can happen in Flash is that particular swf might have problems. You can't bring down a system by missetting a property in Flash.

According to Ron Wheeler, I'm a bad coder.  I respectfully disagree. :)

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to