Since the advent of AS3 I have been working like this:
private var loggy:String;
public function getLoggy ():String
{
return loggy;
}
public function setLoggy ( loggy:String ):void
{
// checking to make sure loggy's new value is kosher etc...
this.loggy = loggy;
}
and have avoided working like this:
private var _loggy:String;
public function get loggy ():String
{
return _loggy;
}
public function set loggy ( loggy:String ):void
{
// checking to make sure loggy's new value is kosher etc...
_loggy = loggy;
}
I have avoided using AS3's implicit getters/setters partly so that I can just start typing "get.." and content assist will give me a list of all my getters, and likewise for my setters. I also dislike underscores in my code which turned me off the implicit route.
Another reason is that I prefer the feel of this:
whateverObject.setLoggy( "loggy's awesome new value!" );
to this:
whateverObject.loggy = "loggy's awesome new value!";
I feel that the former better reflects what is actually happening in the code. I am calling functions, not setting values directly.
After installing Flash Builder and the great new plugin SourceMate ( which helps to get some of the useful features that FDT is famous into FB ) I realized that when I use SourceMate's "generate getters and setters" feature it automatically sets my code up using the implicit route:
private var _loggy:String;
public function get loggy ():String
{
return _loggy;
}
public function set loggy ( loggy:String ):void
{
// do whatever is needed to check to make sure loggy is an acceptable value
_loggy = loggy;
}
I figure that these SourceMate people must know what they are doing or they wouldn't be writing workflow enhancement plugins for coding in AS3, so now I am questioning my ways.
So my question to you is: Can anyone give me a good reason why I should give up my explicit g/s ways, start using the implicit technique, and embrace those stinky little _underscores for my private vars? Or back me up in my reasons for doing things the way that I do?