Obviously I would not suggest breaking encapsulation.  I guess I would
suggest not 'generating' accessors/mutators rather give it thought and
add them as you should.  Also I was trying, although I admit poorly,
to make sure a Java developer coming into Flex/AS3 does not miss some
of the powerful things provided that Java does not provide like
implicit getters/setters.  

For example...

public class MyClass
{
    public var message:String
}

is the same as:

public class MyClass
{
    private var _message:String

    public function get message() : String
    {
        return message
    }

    public function set message( message:String ) : void
    {
        _message = message
    }
}

If you need to do something 'extra' in the getter/setter later you
still can in the first instance but if you don't, the second option is
overly verbose and doesn't take advantage of the languages richness
and implicit getters and setters.  Generating getters and setter when
they are provided 'invisibly' is foolish and wasted effort for
FlexBuilder developers.  Let them focus on more interesting things and
not on sedating us Java developers that want to do it the Java-way and
are reluctant to understand the interesting features of a new language.

"Forget the old and learn new..."  Java is static but ActionScript3
has some neat dynamic features that we shouldn't get crazy with but we
should take advantage of when applicable.  Always keep the brain
engaged.  Not religious, just good advice.  Put your braces where you
want to.  Mine will be lined up though.  ;-)

- Todd

--- In [email protected], "Gregor Kiddie" <[EMAIL PROTECTED]> wrote:
>
> You're getting into religious war territory there my friend! One that's
> been doing the blogs recently too...
> 
> The OP wanted a way of generating getters / setters automatically...
> 
> If we are running a master class here... I would suggest that you only
> ever generate getters for your model, and encapsulate the behaviour of
> the model in functions that relate to your use cases.
> 
> Using public variables in the place of getters and setters reduces the
> level of thought required to code, but not necessarily in a good way as
> it then becomes much easier to break encapsulation.
> 
> But as I said, religious war territory (and didn't we go through this
> recently on this list?)
> 
>  
> 
> Gk.
> 
> Gregor Kiddie
> Senior Developer
> INPS
> 
> Tel:       01382 564343
> 
> Registered address: The Bread Factory, 1a Broughton Street, London SW8
> 3QJ
> 
> Registered Number: 1788577
> 
> Registered in the UK
> 
> Visit our Internet Web site at www.inps.co.uk
> <blocked::http://www.inps.co.uk/> 
> 
> The information in this internet email is confidential and is intended
> solely for the addressee. Access, copying or re-use of information in it
> by anyone else is not authorised. Any views or opinions presented are
> solely those of the author and do not necessarily represent those of
> INPS or any of its affiliates. If you are not the intended recipient
> please contact [EMAIL PROTECTED]
> 
> ________________________________
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of twcrone70
> Sent: 20 June 2008 15:34
> To: [email protected]
> Subject: [flexcoders] Re: A great feature for Flex Builder would be
> getter and setter automation.
> 
>  
> 
> Please remember that if all you need is default behavior as the script
> you provided does, that is implicitly provided by creating your var
> public in AS3.
> 
> Yes, it feels funny having a public member variable coming from Java
> since it is bad to expose your objects state. But, if you need to
> "intercept" the set or get then you can provide the get and/or set
> method and your other code need not change. You only need getters and
> setters in Java from the start because there is not implicit mechanism
> for them. Having getters and setters that are unnecessary and do
> nothing special just bloats your code. So for that, I see getter and
> setter generation for Flex/AS3 as unnecessary.
> 
> One last thing that will surely make eyes roll but...you should be
> careful when arbitrarily generating getters and setters without
> considering if that is what you REALLY should do. In the Java world,
> we too often simply create some fields, generate getters and setters,
> use the default constructor only. We then use the "class" like a
> C-style struct with essentially public fields anyway. Keep your mind
> engaged when developing classes. If you are generating lots of code
> that you never refactor to something more pertinent to your domain,
> you have a very 'dead' model.
> 
> - Todd
>


Reply via email to