I'm the opposite end of the spectrum. This: class Box extends UIObject { function doStuff() { move(x + 10, y + 10); setSize(width + 100, height + 100); visible = !visible; } }
looks more readable to me than: class Box extends UIObject { function doStuff() { this.move(this.x + 10, this.y + 10); this.setSize(this.width + 100, this.height + 100); this.visible = !this.visible; } } To each their own. I can see it justified in extending intrinsic classes, as the first parameter to setInterval, and the first parameter in Delegate. AS3 and Flex both hammer the point that this really has little use other than confirming for those programmers who are not familiar with ActionScript. Same goes for the Singleton.method vs. Singleton.getInstance().method argument; the latter is for those programmers who don't know ActionScript well. If you do it every day, there is no point. ----- Original Message ----- From: "Muzak" <[EMAIL PROTECTED]> To: "Flashcoders mailing list" <flashcoders@chattyfig.figleaf.com> Sent: Friday, October 28, 2005 5:37 PM Subject: Re: [Flashcoders] Newbie AS3 question Well, to me it's the other way around. Code that doesn't use proper references looks messy to me. Whe I'm lazy or in a hurry, I do skip them, but I usually find myself adding them afterwards anyway. So, I'm with ryanm on this one ;-) regards, Muzak ----- Original Message ----- From: "Martin Wood" <[EMAIL PROTECTED]> To: "Flashcoders mailing list" <flashcoders@chattyfig.figleaf.com> Sent: Friday, October 28, 2005 11:03 PM Subject: Re: [Flashcoders] Newbie AS3 question > > > ryanm wrote: >>> What I don't get is why it needs "this.addChild" instead of just >>> addChild. I've been sick of the keyword "this" for a long time >>> and have since avoided it in AS2. >>> >>> Any reason that it needs to be back in for AS3? >>> >> Maybe because it's one of the most useful scope references ever >> invented? >> >> The fundamental concept that you seem to miss is that "addChild" is >> meaningless by itself, it is a method of an object (in >> proper OOP development), and if you just say "addChild", who is adding >> the child? > > the context is the current class. Occasionally 'this' is useful if you > happen to name a method parameter or local variable the > same as a member variable and need to distinguish the two. > > But, I dont agree that its bad form to leave it out, nor is it any more > difficult to maintain. > > in my opinion putting 'this' in everywhere to me just makes things harder > to read. > > thanks, > > Martin _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders