R
Rob
Hi All,
I just wanted to get some of your opinions on the approach I am using
for a small windows forms app I am writing in VB.NET.
First of all I have kept all of my data classes seperated from my GUI
classes - no user interaction is required within any data class. To
interact with the data classes I will create a new instance of a form
class. For example I would create a new frmMyDataClass which would
contain it's own instance of MyDataClass. The form has the means to
change all of the relevant public properties within MyDataClass.
Whenever a property of the Data class is modified it will raise an
event. For example if I set me.MyDataClass.Name = "newName" then the
data class will raise a NameChanged event using MyDataClassEventArgs
that is bubbled back to the calling form. The event is a custom event
so it contains a reference to the instance of MyDataClass that was
changed.
This then allows my form class to be notified whenever the data that
it represents has changed and update the form accordingly. This will
ensure I don't ever forget to visually update whatever changes have
been made.
Is this a silly approach? Should I just do something more like:-
me.MyDataClass.Name = "newName"
me.text = me.MYDataClass.Name
.... and make sure that I don't forget to do the visual update?
Thanks,
Rob
I just wanted to get some of your opinions on the approach I am using
for a small windows forms app I am writing in VB.NET.
First of all I have kept all of my data classes seperated from my GUI
classes - no user interaction is required within any data class. To
interact with the data classes I will create a new instance of a form
class. For example I would create a new frmMyDataClass which would
contain it's own instance of MyDataClass. The form has the means to
change all of the relevant public properties within MyDataClass.
Whenever a property of the Data class is modified it will raise an
event. For example if I set me.MyDataClass.Name = "newName" then the
data class will raise a NameChanged event using MyDataClassEventArgs
that is bubbled back to the calling form. The event is a custom event
so it contains a reference to the instance of MyDataClass that was
changed.
This then allows my form class to be notified whenever the data that
it represents has changed and update the form accordingly. This will
ensure I don't ever forget to visually update whatever changes have
been made.
Is this a silly approach? Should I just do something more like:-
me.MyDataClass.Name = "newName"
me.text = me.MYDataClass.Name
.... and make sure that I don't forget to do the visual update?
Thanks,
Rob