Further derail! What are people's thoughts on implicit vs. explicit accessors? I prefer explicit ones, but I confess that it's almost entirely because I learned Java before Actionscript. You can't argue that explicit setters are required for a "serious" language, because C# prefers implicit setters. (For the sake of argument, let's just agree that C# is a serious object-oriented language.)

From a practical standpoint, using myObject.property is perfectly effective. If it's a property that should be insulated from direct modification, you just apply a public implicit getter to a private field. If it's a property that need not be insulated, such as MovieClip._x, why not just make it public? As long as the naming and effects are consistent, I don't see a practical drawback.

Theoretically, though, I like explicit setters because they make it very clear that you're calling methods which act on internal fields. myObject.getProperty() tells the coder "you're getting a value, but NOT necessarily the value of any particular internal field," while myObject.property implies that they're getting internal state from the object. (Another advantage, in Actionscript, is that using explicit setters reserves pure dot-notation for movieclip paths: foo.bar.baz must clearly be a MovieClip nesting, while foo.getBar().getBaz() must clearly be class objects.)

In the end, my choice of explicit setters is based on habit and personal preference. Opinions?

_______________________________________________
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