Re: [flexcoders] General list consensus using 'this' when referencing local vars

2008-04-08 Thread Bjorn Schultheiss

drop the 'this' unless its necessary to explain something..


On 08/04/2008, at 5:39 PM, Mike Anderson wrote:



Greetings All,

Whenever I study code generated by seasoned programmers (i.e. all  
the Adobe people supporting Flex on this list) as well as countless  
others on this list, I notice that some use this when referencing  
local variables contained within a Class.


The last thing I want to do here, is start a heated discussion  
regarding best practices for programming.  My goal on a daily  
basis, is to better myself as a programmer, and I want to make sure  
that the code I create, conforms to certain standards.


Could some of you please offer your 2 Cents regarding the advantages/ 
disadvantages of using this?  Just a quick example:


package
{
public class myClass()
{
private var testVar:String;

public function myClass( value:String )
{
this.testVar = value;
// versus:
testVar = value;
}
}
}

Thank you all so much in advance, for any help you can offer  
regarding this topic.


Mike







Re: [flexcoders] General list consensus using 'this' when referencing local vars

2008-04-08 Thread Christian
I personally prefer to use it, as it makes it clearer for me later when I
come back as to what is a class member/function and what is in the
local/global scope. I say use which one you prefer. I came from a java
background, and I remember always using 'this' with java classes. But that's
just my 2 cents. :) It can be helpfully for when you come back to code and
you're trying to remember what you did.

On Tue, Apr 8, 2008 at 4:51 PM, Bjorn Schultheiss 
[EMAIL PROTECTED] wrote:

   drop the 'this' unless its necessary to explain something..


 On 08/04/2008, at 5:39 PM, Mike Anderson wrote:


 Greetings All,

 Whenever I study code generated by seasoned programmers (i.e. all the
 Adobe people supporting Flex on this list) as well as countless others on
 this list, I notice that some use this when referencing local variables
 contained within a Class.

 The last thing I want to do here, is start a heated discussion regarding
 best practices for programming.  My goal on a daily basis, is to better
 myself as a programmer, and I want to make sure that the code I create,
 conforms to certain standards.

 Could some of you please offer your 2 Cents regarding the
 advantages/disadvantages of using this?  Just a quick example:

 package
 {
 public class myClass()
 {
 private var testVar:String;

 public function myClass( value:String )
 {
 this.testVar = value;
 // versus:
 testVar = value;
 }
 }
 }

 Thank you all so much in advance, for any help you can offer regarding
 this topic.

 Mike



  




-- 

Every child has many wishes. Some include a wallet, two chicks and a cigar,
but that's another story.


Re: [flexcoders] General list consensus using 'this' when referencing local vars

2008-04-08 Thread shaun
Mike Anderson wrote:
 Greetings All,
  
 Whenever I study code generated by seasoned programmers (i.e. all the
 Adobe people supporting Flex on this list) as well as countless others
 on this list, I notice that some use this when referencing local
 variables contained within a Class.
  
 The last thing I want to do here, is start a heated discussion regarding
 best practices for programming.  My goal on a daily basis, is to
 better myself as a programmer, and I want to make sure that the code I
 create, conforms to certain standards.
  
 Could some of you please offer your 2 Cents regarding the
 advantages/disadvantages of using this?  Just a quick example:
  
 package
 {
 public class myClass()
 {
 private var testVar:String;
 
 public function myClass( value:String )
 {
 this.testVar = value;
 // versus:
 testVar = value;
 }
 }
 }

Something to consider is the naming of the function parameters used.
eg)
  public class myClass()
  {
  protected var valueOne:String;
  protected var valueTwo:String;

  public function myClass( valueOne:String, valueTwo:String )
  {
  this.valueOne = valueOne; // ok
  valueTwo = valueTwo;  //?? erk
  }
  }
  }

cheers,
  - shaun



Re: [flexcoders] General list consensus using 'this' when referencing local vars

2008-04-08 Thread Giles Roadnight
ctrl - space?

On Tue, Apr 8, 2008 at 10:55 AM, Scott Melby [EMAIL PROTECTED] wrote:

   I am not a big fan of the this, but it is the way I get flexbuilder to

 offer code assistance so I don't have to remember and type out the names
 of the methods and member variables of my class. So... it frequently
 ends up staying in the code. If there were a hot-key sequence that
 produced the same list I don't think I'd ever have this in my code
 again.

 Scott

 Scott Melby
 Founder, Fast Lane Software LLC
 http://www.fastlanesw.com
 http://blog.fastlanesw.com


 Bjorn Schultheiss wrote:
  drop the 'this' unless its necessary to explain something..
 
 
  On 08/04/2008, at 5:39 PM, Mike Anderson wrote:
 
 
  Greetings All,
 
  Whenever I study code generated by seasoned programmers (i.e. all the
  Adobe people supporting Flex on this list) as well as countless
  others on this list, I notice that some use this when referencing
  local variables contained within a Class.
 
  The last thing I want to do here, is start a heated discussion
  regarding best practices for programming. My goal on a daily
  basis, is to better myself as a programmer, and I want to make sure
  that the code I create, conforms to certain standards.
 
  Could some of you please offer your 2 Cents regarding the
  advantages/disadvantages of using this? Just a quick example:
 
  package
  {
  public class myClass()
  {
  private var testVar:String;
 
  public function myClass( value:String )
  {
  this.testVar = value;
  // versus:
  testVar = value;
  }
  }
  }
 
  Thank you all so much in advance, for any help you can offer
  regarding this topic.
 
  Mike
 
 
 
 
 

  




-- 
Giles Roadnight
http://giles.roadnight.name


Re: [flexcoders] General list consensus using 'this' when referencing local vars

2008-04-08 Thread Scott Melby
I am not a big fan of the this, but it is the way I get flexbuilder to 
offer code assistance so I don't have to remember and type out the names 
of the methods and member variables of my class.  So... it frequently 
ends up staying in the code.  If there were a hot-key sequence that 
produced the same list I don't think I'd ever have this in my code again.

Scott

Scott Melby
Founder, Fast Lane Software LLC
http://www.fastlanesw.com
http://blog.fastlanesw.com



Bjorn Schultheiss wrote:
 drop the 'this' unless its necessary to explain something..


 On 08/04/2008, at 5:39 PM, Mike Anderson wrote:


 Greetings All,

 Whenever I study code generated by seasoned programmers (i.e. all the 
 Adobe people supporting Flex on this list) as well as countless 
 others on this list, I notice that some use this when referencing 
 local variables contained within a Class.

 The last thing I want to do here, is start a heated discussion 
 regarding best practices for programming.  My goal on a daily 
 basis, is to better myself as a programmer, and I want to make sure 
 that the code I create, conforms to certain standards.

 Could some of you please offer your 2 Cents regarding the 
 advantages/disadvantages of using this?  Just a quick example:

 package
 {
 public class myClass()
 {
 private var testVar:String;

 public function myClass( value:String )
 {
 this.testVar = value;
 // versus:
 testVar = value;
 }
 }
 }

 Thank you all so much in advance, for any help you can offer 
 regarding this topic.

 Mike








Re: [flexcoders] General list consensus using 'this' when referencing local vars

2008-04-08 Thread Scott Melby
A great practice is to put a prefix on member variables to avoid exactly 
what Shaun is talking about.  I typically use an underscore as follows.  
This completely eliminates the need for the this even for readability 
sake.  Additionally I pretty much use only private members.  If I want 
to expose a property I write a getter and/or setter as appropriate.


public class myClass
{
  private var _valueOne:String; 
  private var _valueTwo:String;

  public function myClass( valueOne:String, valueTwo:String )
  {
 this._valueOne = valueOne; // ok
 _valueTwo = valueTwo;  // also OK
  }

  //value one is read only
  public function get valueOne():String
  {
 return _valueOne;
  }

  //value two is read/write
  public function get valueTwo():String
  {
 return _valueTwo;
  }

  public function set valueTwo(valueTwo:String):void
  {
 _valueTwo = valueTwo;
  }
}

2 more of my cents :)
Scott

Scott Melby
Founder, Fast Lane Software LLC
http://www.fastlanesw.com
http://blog.fastlanesw.com



shaun wrote:

Mike Anderson wrote:
  

Greetings All,
 
Whenever I study code generated by seasoned programmers (i.e. all the

Adobe people supporting Flex on this list) as well as countless others
on this list, I notice that some use this when referencing local
variables contained within a Class.
 
The last thing I want to do here, is start a heated discussion regarding

best practices for programming.  My goal on a daily basis, is to
better myself as a programmer, and I want to make sure that the code I
create, conforms to certain standards.
 
Could some of you please offer your 2 Cents regarding the

advantages/disadvantages of using this?  Just a quick example:
 
package

{
public class myClass()
{
private var testVar:String;

public function myClass( value:String )

{
this.testVar = value;
// versus:
testVar = value;
}
}
}



Something to consider is the naming of the function parameters used.
eg)
  public class myClass()
  {
  protected var valueOne:String;
  protected var valueTwo:String;

  public function myClass( valueOne:String, valueTwo:String )
  {
  this.valueOne = valueOne; // ok
  valueTwo = valueTwo;  //?? erk
  }
  }
  }

cheers,
  - shaun


  


Re: [flexcoders] General list consensus using 'this' when referencing local vars

2008-04-08 Thread Scott Melby
NICE... actually that is even better since it includes locals as well as 
members etc.  Guess I should have said If I knew of a hot-key sequence :)


Thanks!
Scott

Scott Melby
Founder, Fast Lane Software LLC
http://www.fastlanesw.com
http://blog.fastlanesw.com



Giles Roadnight wrote:

ctrl - space?

On Tue, Apr 8, 2008 at 10:55 AM, Scott Melby [EMAIL PROTECTED] wrote:

  

  I am not a big fan of the this, but it is the way I get flexbuilder to

offer code assistance so I don't have to remember and type out the names
of the methods and member variables of my class. So... it frequently
ends up staying in the code. If there were a hot-key sequence that
produced the same list I don't think I'd ever have this in my code
again.

Scott

Scott Melby
Founder, Fast Lane Software LLC
http://www.fastlanesw.com
http://blog.fastlanesw.com


Bjorn Schultheiss wrote:


drop the 'this' unless its necessary to explain something..


On 08/04/2008, at 5:39 PM, Mike Anderson wrote:

  

Greetings All,

Whenever I study code generated by seasoned programmers (i.e. all the
Adobe people supporting Flex on this list) as well as countless
others on this list, I notice that some use this when referencing
local variables contained within a Class.

The last thing I want to do here, is start a heated discussion
regarding best practices for programming. My goal on a daily
basis, is to better myself as a programmer, and I want to make sure
that the code I create, conforms to certain standards.

Could some of you please offer your 2 Cents regarding the
advantages/disadvantages of using this? Just a quick example:

package
{
public class myClass()
{
private var testVar:String;

public function myClass( value:String )
{
this.testVar = value;
// versus:
testVar = value;
}
}
}

Thank you all so much in advance, for any help you can offer
regarding this topic.

Mike