sometimes protected members are essential and putting them in the public API makes no sense.
With flex components, I have found that wrapping a protected variables function with a public API saves this problem and allows the developer to allow access into the protected API very safely.
I also understand what you say about composition, there needs to be a line with protected members that allows the distinction between function and interface.
Peace, Mike
Have you ever tried to subclass CartesianChart to draw a rectangle right
on the chart?
The property dataRegion is declared as protected, but I need to be able
to instantiate and use this property from a class or MXML that is not a
descendent of CartesianChart. Of course, there is a workaround, you can
create a subclass and add a public method there that will return you
the dataRegion. But my question is more generic: why use protected
variables at all? If you want to hide a variable, make it private. If
you want to give an access to a variable, still make it private but
provide a public accessor.
I made a post at JavaLobby, a popular forum on the subject over here:
http://www.javalobby.org/java/forums/t77911.html
I provided a simple example in Java just to prove my point, but the same
considerations are valid to all Flex components including the ones
developed by Adobe, sorry guys, no offence.
More than five thousand Java developers have read this post, and so far
no one gave me a good reason to use protected variables. Read the
discussion of this JavaLobby thread. To summarize, people think this
way: "As a designer of my component, I ask myself, should people use
this property from anywhere but a subclass of my component? If the
answer is no, I make it protected". IMHO, designers of components
should not even ask themselves such a question.
If you give me your component, do not stop me from using composition,
please...Besides, I know a workaround described in my Java post.
Regards,
Yakov Fain
Farata Systems
www.faratasystems.com
--
What goes up, does come down. __._,_.___![]()
SPONSORED LINKS
Custom software development Database development software Embedded software development Offshore software development Software development
YAHOO! GROUPS LINKS
- Visit your group "flexcomponents" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
__,_._,___
- [flexcomponents] Avoid using protected variables in your ... Yakov Fain
- Re: [flexcomponents] Avoid using protected variables... Michael Schmalle
Reply via email to
