PC Review


Reply
Thread Tools Rate Thread

Advice on Coding standards

 
 
=?Utf-8?B?dnZlbms=?=
Guest
Posts: n/a
 
      21st Nov 2004
Hello:

Is it just a good practice to fully qualify an object reference or does it
enhance performance?

For instance, if I have a Combo box, cmbMyCombo, on a form, which is better?

1. cmbMyCombo.SelectedIndex = 0
or
2. Me.cmbMyCombo.SelectedIndex = 0

Thanks for your advice.

Venkat
 
Reply With Quote
 
 
 
 
John Smith
Guest
Posts: n/a
 
      21st Nov 2004
> Is it just a good practice to fully qualify an object reference or does it
> enhance performance?


Neither. It makes the lines longer. It is actually only used at compilation
stage as it is a 'language feature' and not something you will see in the
resulting binary file. Therefore there is absolutely no performance
difference.

> For instance, if I have a Combo box, cmbMyCombo, on a form, which is

better?
>
> 1. cmbMyCombo.SelectedIndex = 0
> or
> 2. Me.cmbMyCombo.SelectedIndex = 0


Neither is better. For the 1st one I'd be in doubt if it is a class or a
local variable. How can I tell that from the name?
For the 2nd line I'd say it's useless to write it out fully because it
doesn't make me much smarter except that I know now that it belongs to the
class.

In the old days with MFC, Microsoft had something they called hungarien
notation. For variables you should specify "m_" infront of the variable.
This tells that the variable is a member of the class.
It's quite commonly used on other languages like java too and these days
comes in various forms: _var1, m_var1 or var1_.

Personally I use something like m_nValue meaning an integer value belonging
to the class. If it'd be a local variable I'd use nValue instead.

-- John


 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      21st Nov 2004
Venkat,

Me is for two things usable in one you have to, in the other it is simple

When you create a variable (object or value) in your class with the same
name as in another class that you are using, you have to use "me" to
distinct it from that other class

Me is as well very handy to use the intelisence.

It has as John already said it has no effect on your production program.

I hope this helps?

Cor


 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      21st Nov 2004

Me is for two things usable in one you have to, in the other it is simple
handy



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      21st Nov 2004
"vvenk" <(E-Mail Removed)> schrieb:
> Is it just a good practice to fully qualify an object
> reference or does it enhance performance?
>
> For instance, if I have a Combo box, cmbMyCombo,
> on a form, which is better?
>
> 1. cmbMyCombo.SelectedIndex = 0
> or
> 2. Me.cmbMyCombo.SelectedIndex = 0


Personal preference (both samples will be compiled to the same IL). I use
'Me.' because it will give me IntelliSense to select the control.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET Coding Standards =?Utf-8?B?UHJhdmVlbg==?= Microsoft ASP .NET 4 12th Aug 2004 01:37 PM
VB Coding Standards Dan Schaertel Microsoft VB .NET 3 8th Jan 2004 10:22 PM
Coding Standards for VB.NET Dotnetjunky Microsoft VB .NET 4 24th Dec 2003 01:30 PM
.Net coding standards mish Microsoft Dot NET 0 24th Sep 2003 10:01 PM
coding standards shbgupta Microsoft ASP .NET 2 27th Jun 2003 09:48 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:32 AM.