OO confusion

baptismo

New member
Joined
Nov 10, 2009
Messages
1
Programming Experience
1-3
Hi All,

I've got 2 classes, one called row and one called value. The row class has an array of value as one of its properties. The row class also has a property called flag which will contain an enum for how it has changed.

on the setter for value i was hoping to update the flag property of row, but i cant work out how to do it via modern OO. Here's the code:

Public Class Row
'Variables
Private values_local() As Value
Private flag_local As DataFlags

'Properties
Property values() As Value()
Get
Return Me.values_local
End Get
Set(ByVal values_new As Value())
Me.values_local = values_new
End Set
End Property

Property flag() As DataFlags
Get
Return Me.flag_local
End Get
Set(ByVal flag_new As DataFlags)
Me.flag_local = DataFlags.update
End Set
End Property

'Constructors
Public Sub New()
End Sub
End Class

Public Class Value
'Variables
Private value_local As Object

'Properties
Property value() As Object
Get
Return Me.value_local
End Get
Set(ByVal value_new As Object)
Me.value_local = value_new
'NEED TO SET THE FLAG OF THE ROW WHICH CONTAINS VALUE HERE!
End Set
End Property

'Constructors
Public Sub New(ByVal value As Object)
'add new custom data types into this if statement for ie: a sql server geometry object
If value.GetType().ToString() = Datatypes.sdo_geometry Then
Me.value_local = New SdoGeometry
Me.value_local = DirectCast(value, SdoGeometry)
Else
Me.value_local = New Data(value)
End If
End Sub
End Class

Any help of thought greatly appreciated...
 
There really is no way to do that because there is no direct relationship between the Row and the Value. The way your classes are defined isn't really conducive to what you want to do. As it is, you'd have to add an event to your Value property to indicate that its 'value' property had changed. The Row would then have to handle that event but the problem is how to add the event handler. When you set the 'values' property you could run through and remove and add event handlers as needed but what happens if you set one of the elements of the array externally? There's no way for your Row object to know that that's happened.

By the way, it's convention for property names to begin with an upper case letter. There's no reason for you not to follow that convention.
 
Back
Top