no, I just wanted to make a joke ;-)

Yes, of course if property has some logic which checks the set value or
count the get value from something then yes, you should use the property,
but why to use it when it contains only eg get {return this.value} ? and one
more thing about your message:
-If the property is read-only, then there is a reason for this (i.e. logic
already exists internally to set the value of the underlying field)
and that logic is? Sorry, but I don't quite understand that, coding classes
always means to create some its own logic and how does look a logic to set
the variable? Maybe this.variable = value? Oh no, sry, you can't, you must
use property for this... but property is read-only? Damn, so there already
MUST be some logic that sets it...
--that was test of some irony, don't get it personally ;-)

2009/12/17 Jamie Fraser <[email protected]>

> If the variable is only used internally, you wouldn't have a property in
> the first place, would you? And then you access the field directly, I
> thought that much was obvious. A property exists (in most cases) to have a
> single point of access for a class-level field. For a field which is never
> accessed externally, you don't ever create a property (unless, of course,
> getting / setting this property encapsulates more than a simple get/set, in
> which case a property might be appropriate)
>
> If the variable is to be accessed internally AND externally, then you use
> the property both internally and externally. The property may encapsulate
> lazy loading, validation, value checking etc, so why would you bypass this
> logic?
>
> If the property is read-only, then there is a reason for this (i.e. logic
> already exists internally to set the value of the underlying field), again
> common sense rules here and you access the field directly when SETTING, but
> use the property when GETTING.
>
> Finally - if you have any more pathetic comments about my level of ability,
> kindly keep them to yourself. Insulting other members of the group simply
> serves to highlight your own inadequacy.
>
>
>
>
>
>
> On Thu, Dec 17, 2009 at 10:00 AM, Processor Devil <
> [email protected]> wrote:
>
>> Dear Jamie...
>> and what about you don't need any variable to be accessible from the
>> outside of the class, how would you access the value? Would you make one
>> useless property? And what about if you want the property to be read only,
>> how would you change the value?
>>
>> Sorry to tell you, but the guy who taught you programming should return
>> you money for the lessons...
>>
>> 2009/12/17 Jamie Fraser <[email protected]>
>>
>> Inside the class, you should use the property. Outside of the class, you
>>> should also use the property.
>>>
>>>
>>> On Wed, Dec 16, 2009 at 9:18 AM, Processor Devil <
>>> [email protected]> wrote:
>>>
>>>> inside the same class use i = me._intID :)
>>>> class properties are used to set or get the variable content out of the
>>>> current class scope, but yes, either works
>>>>
>>>> 2009/12/16 hanks2000 <[email protected]>
>>>>
>>>> oops sorry posted by accident, here's the complete example
>>>>>
>>>>> Public Property ID() As Integer
>>>>>        Get
>>>>>            Return _intID
>>>>>        End Get
>>>>>        Set(ByVal value As Integer)
>>>>>            If Not _intID = value Then
>>>>>                _intID = value
>>>>>            End If
>>>>>        End Set
>>>>>    End Property
>>>>>
>>>>>
>>>>> Private Sub SomeMethod()
>>>>>    Dim i As Integer = 0
>>>>>
>>>>>     'use this
>>>>>    i = me._intID
>>>>>
>>>>>    'or this
>>>>>    i = me.ID
>>>>> End Sub
>>>>>
>>>>>
>>>>> Thanks
>>>>>
>>>>
>>>>
>>>
>>
>

Reply via email to