If i have this property
Dim m_name as string
Property name() as string
Get
return m_name
end Get
Set (byval Value as string)
m_name = Value
End set
End property
In my code i have to use m_name or name ? 11 1438
You would use m_name inside the class that has this property. When setting
or getting the name property from outside the class, you would use name.
"ucasesoftware" <uc***********@hotmail.fr> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com... If i have this property
Dim m_name as string
Property name() as string Get return m_name end Get Set (byval Value as string) m_name = Value End set End property
In my code i have to use m_name or name ?
ok thx
One other question :
in class method... can i use sql connexion like that ? or... it's not
good ?
Public Class monAgenda
Dim m_agendaGuid As Guid
Property agendaGuid() As Guid
Get
Return m_agendaGuid
End Get
Set(ByVal Value As Guid)
m_agendaGuid = Value
End Set
End Property
Dim m_entrepriseGuid As Guid
Property entrepriseGuid() As Guid
Get
Return m_entrepriseGuid
End Get
Set(ByVal Value As Guid)
m_entrepriseGuid = Value
End Set
End Property
Dim m_salarieGuid As Guid
Property salarieGuid() As Guid
Get
Return m_salarieGuid
End Get
Set(ByVal Value As Guid)
m_salarieGuid = Value
End Set
End Property
Dim m_agendaNom As String
Property agendaNom() As String
Get
Return m_agendaNom
End Get
Set(ByVal Value As String)
m_agendaNom = Value
End Set
End Property
Dim m_firstHour As String
Property firstHour() As String
Get
Return m_firstHour
End Get
Set(ByVal Value As String)
m_firstHour = Value
End Set
End Property
Dim m_workHourBegin As String
Property workHourBegin() As String
Get
Return m_workHourBegin
End Get
Set(ByVal Value As String)
m_workHourBegin = Value
End Set
End Property
Dim m_workHourEnd As String
Property workHourEnd() As String
Get
Return m_workHourEnd
End Get
Set(ByVal Value As String)
m_workHourEnd = Value
End Set
End Property
Dim m_hourResolution As String
Property hourResolution() As String
Get
Return m_hourResolution
End Get
Set(ByVal Value As String)
m_hourResolution = Value
End Set
End Property
Dim m_isRdv As Boolean
Property isRdv() As Boolean
Get
Return m_isRdv
End Get
Set(ByVal Value As Boolean)
m_isRdv = Value
End Set
End Property
Dim m_template As String
Property template() As String
Get
Return m_template
End Get
Set(ByVal Value As String)
m_template = Value
End Set
End Property
Public Function agendaOwner(ByVal salarieGuid As Guid) As String
Try
Dim myConnexion As New SqlConnection
ouvreConnexion(myConnexion)
Dim cmd As SqlCommand
cmd = New SqlCommand("SELECT salarie.prenom + ' ' +
salarie.nom + ' (' + entreprise.raisonSociale + ')' AS nomComplet FROM
salarie INNER JOIN entreprise ON salarie.entrepriseGuid =
entreprise.entrepriseGuid where salarieGuid = '" & salarieGuid.ToString
& "'", myConnexion)
Return cmd.ExecuteScalar
Catch ex As Exception
monErreur(ex)
End Try
End Function
End Class
"Terry Olsen" <to******@hotmail.com> schrieb: You would use m_name inside the class that has this property. When setting or getting the name property from outside the class, you would use name.
Personal preference. I prefer using the property over the private variable,
because this would add the benefit of validation, especially when assigning
a new value to the property.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
and for my question about sql connexion ?
i do not concure with that ,,,,,
i use the property name inside the class with the me prefix ( although
without is also valid however, i am lazy so i use the intellisense
feature )
property`s might encapsulate validators / constrainst / business logic
that is why it is always good coding practice to use them instead of the
underlying variabels
And yes it is valid to use a sql connection like that in your class code
regards
Michel Posseth [MCP]
"Terry Olsen" <to******@hotmail.com> schreef in bericht
news:uU**************@tk2msftngp13.phx.gbl... You would use m_name inside the class that has this property. When setting or getting the name property from outside the class, you would use name.
"ucasesoftware" <uc***********@hotmail.fr> wrote in message news:11**********************@o13g2000cwo.googlegr oups.com... If i have this property
Dim m_name as string
Property name() as string Get return m_name end Get Set (byval Value as string) m_name = Value End set End property
In my code i have to use m_name or name ?
"ucasesoftware" <uc***********@hotmail.fr> schrieb Dim m_agendaGuid As Guid Property agendaGuid() As Guid Get Return m_agendaGuid End Get Set(ByVal Value As Guid) m_agendaGuid = Value End Set End Property
I recommend not using property procedures in this case because they don't do
anything but get/set the value. Use a Public field instead (Public
agendaGuid As Guid).
Armin
"ucasesoftware" <uc***********@hotmail.fr> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com... If i have this property
Dim m_name as string
Property name() as string Get return m_name end Get Set (byval Value as string) m_name = Value End set End property
In my code i have to use m_name or name ?
Since the example Get/Set accessors have no
validation, you don't need the property at all.
A public variable alone would suffice.
Public m_Name As String
You then access m_Name both inside and outside
of the class.
However, if validation is required, it's always
better to use a private variable with access to it
via the property (which includes the validation
code), both inside and outside of the class.
In other words, "keep your powder dry".
"Micky" <mi***@n05pam.com> schrieb: If i have this property
Dim m_name as string
Property name() as string Get return m_name end Get Set (byval Value as string) m_name = Value End set End property
In my code i have to use m_name or name ?
Since the example Get/Set accessors have no validation, you don't need the property at all. A public variable alone would suffice.
Public m_Name As String
You then access m_Name both inside and outside of the class.
I have to disagree. Properties are the way to go when modeling an entity's
attributes. Additionally, changing the implementation of the property
(i.e., adding validation) would not break client code using the class,
whereas changing the public variable to a property will do.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message news:uT**************@TK2MSFTNGP09.phx.gbl... "Micky" <mi***@n05pam.com> schrieb: If i have this property
Dim m_name as string
Property name() as string Get return m_name end Get Set (byval Value as string) m_name = Value End set End property
In my code i have to use m_name or name ?
Since the example Get/Set accessors have no validation, you don't need the property at all. A public variable alone would suffice.
Public m_Name As String
You then access m_Name both inside and outside of the class.
I have to disagree. Properties are the way to go when modeling an entity's attributes. Additionally, changing the implementation of the property (i.e., adding validation) would not break client code using the class, whereas changing the public variable to a property will do.
You make a valid point, Herfried. I stand corrected.
"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... "ucasesoftware" <uc***********@hotmail.fr> schrieb Dim m_agendaGuid As Guid Property agendaGuid() As Guid Get Return m_agendaGuid End Get Set(ByVal Value As Guid) m_agendaGuid = Value End Set End Property
I recommend not using property procedures in this case because they don't do anything but get/set the value. Use a Public field instead (Public agendaGuid As Guid).
I would /still/ argue for using properties, /even if/ all they do is get
or set the value. If you start your application using a field, then
change it to a property later on, you will *break* existing, deployed
code. Besides, you should always /validate/ property values as they
are set (unless they're Boolean's of course).
Regards,
Phill W.
"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> schrieb "Armin Zingler" <az*******@freenet.de> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl... "ucasesoftware" <uc***********@hotmail.fr> schrieb Dim m_agendaGuid As Guid Property agendaGuid() As Guid Get Return m_agendaGuid End Get Set(ByVal Value As Guid) m_agendaGuid = Value End Set End Property I recommend not using property procedures in this case because they don't do anything but get/set the value. Use a Public field instead (Public agendaGuid As Guid).
I would /still/ argue for using properties, /even if/ all they do is get or set the value. If you start your application using a field, then change it to a property later on, you will *break* existing, deployed code.
I design a member based on the current needs or the needs that are planned
for the future. If there's no need to make a property, I use a public field.
I won't make them *all* properties just because one *might* become a
property later. When will it be? Next year? In five years? Probably never?
In other words, I want to look at a component or it's source code at any
given point of time and it must make sense at the same point of time. If I
now look at the op's code, I'd call it bad design because the property
procedures are not necessary.
Later, if it has to be changed to a property, and if this breaks existing
code, well, that's how it is if we change the interface. Better than now
having unnecessary code.
I admit I might have a little more work later, but a) not even the
field's/property's usage changes, b) not very probable and c) better
than now having the work of writing a property instead of a field.
Luckily, the JIT-compiler can optimize these simple properties to inline
field access. :-)
Besides, you should always /validate/ property values as they are set (unless they're Boolean's of course).
If there is something to check, I do use a property. This was not the case
in the op's code.
Armin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: William C. White |
last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using
cURL? Our website is hosted on a shared drive and the webhost company
doesn't installed additional software (such as cURL)...
|
by: Albert Ahtenberg |
last post by:
Hello,
I don't know if it is only me but I was sure that header("Location:url")
redirects the browser instantly to URL, or at least stops the execution of
the code. But appearantely it continues...
|
by: James |
last post by:
Hi,
I have a form with 2 fields.
'A'
'B'
The user completes one of the fields and the form is submitted.
On the results page I want to run a query, but this will change
subject to which...
|
by: Ollivier Robert |
last post by:
Hello,
I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9
system. The link succeeds but everytime I try to run php, I get a SEGV from
inside the libcnltsh.so library.
...
|
by: Richard Galli |
last post by:
I want viewers to compare state laws on a single subject.
Imagine a three-column table with a drop-down box on the top. A viewer
selects a state from the list, and that state's text fills the...
| |
by: Albert Ahtenberg |
last post by:
Hello,
I have two questions.
1. When the user presses the back button and returns to a form he filled
the form is reseted. How do I leave there the values he inserted?
2. When the...
|
by: inderjit S Gabrie |
last post by:
Hi all
Here is the scenerio ...is it possibly to do this...
i am getting valid course dates output on to a web which i have designed
....all is okay so far , look at the following web url
...
|
by: Jack |
last post by:
Hi All,
What is the PHP equivilent of Oracle bind variables in a SQL statement, e.g.
select x from y where z=:parameter
Which in asp/jsp would be followed by some statements to bind a value...
|
by: Sandwick |
last post by:
I am trying to change the size of a drawing so they are all 3x3.
the script below is what i was trying to use to cut it in half ... I
get errors.
I can display the normal picture but not the...
|
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,...
|
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...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |