473,396 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

private variable vs. actual property in a class module?

What's the difference in using the private variable as opposed to the actual
property in a class module? Which is better or more efficient? (
LoginObject.Save (_loginName) or LoginObject.Save (me.LoginName)

FOR EXAMPLE:

Class MyClass

Private _loginName As String
Public Property LoginName() As String
Get
Return _loginName
End Get
Set(ByVal Value As String)
_loginName = Value.ToLower()
End Set
End Property

public sub Save()
dim LoginObject as new Data.LoginObject
'****** what is the difference in these 2 lines? *******
LoginObject.Save (_loginName)
LoginObject.Save (me.LoginName)
'******************************************
end function

End Class
Thank You,

SteveS
Jul 21 '05 #1
1 1659
I don't think it makes any difference the JIT will optimize the Me.LoginName
so there won't be any performance difference.

In my opinion using the property (Me.LoginName) is advisable, because in
that case you're using OO encapsulation.

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
"SteveS" <ss*****@trendmls.com> wrote in message
news:eu**************@TK2MSFTNGP09.phx.gbl...
What's the difference in using the private variable as opposed to the actual property in a class module? Which is better or more efficient? (
LoginObject.Save (_loginName) or LoginObject.Save (me.LoginName)

FOR EXAMPLE:

Class MyClass

Private _loginName As String
Public Property LoginName() As String
Get
Return _loginName
End Get
Set(ByVal Value As String)
_loginName = Value.ToLower()
End Set
End Property

public sub Save()
dim LoginObject as new Data.LoginObject
'****** what is the difference in these 2 lines? *******
LoginObject.Save (_loginName)
LoginObject.Save (me.LoginName)
'******************************************
end function

End Class
Thank You,

SteveS

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: gabor | last post by:
hi, as far as i know in python there aren't any private (i mean not accessible from the outside of the object) methods/fields. why? in java/c++ i can make a method private, this way...
21
by: Anthony England | last post by:
Everyone knows that global variables get re-set in an mdb when an un-handled error is encountered, but it seems that this also happens when the variable is defined as private at form-level. So...
2
by: Bob | last post by:
Is this a bug? Expected behavior? Did I get the binding flags wrong? Bob -------------------- Imports System.Reflection Module Main
7
by: Just Me | last post by:
I have a project that contains a usercontrol, some forms and a module. The only thing in the module is one variable that is there so that it can be used by the control and all the forms. ...
2
by: dumbo | last post by:
Hello, who gives one more shining solution to me? My application load form "A". The form "A" by means of a push-button load form "B" that in its turn by means of a push-button load form "C". Form...
1
by: SteveS | last post by:
What's the difference in using the private variable as opposed to the actual property in a class module? Which is better or more efficient? ( LoginObject.Save (_loginName) or LoginObject.Save...
11
by: prefersgolfing | last post by:
I'm trying to find on MSDN, or someplace, that speaks to variables being public or private by default. Anyone know where? Thanks.
7
by: Victor | last post by:
I just tried a test comparing a Function to a Private Function with this code: <% Option Explicit dim X1 X1 = 9 Private Function RealTest(here) RealTest = here + X1 End Function
17
by: Peng Yu | last post by:
Hi, I'm wondering if there is something in namespace like the 'private' keyword in class? I want to define some class or function that can only be used within that namespace. Thanks, Peng
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.