By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,815 Members | 1,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,815 IT Pros & Developers. It's quick & easy.

Best practice, copy object, using a shadow Object for a undo functionality

P: n/a
Hi,

I am a VB.NET newbie that would like to know the best practise when
working with objects and undo user changes to objects properties.

Problem
The system allows the user to change properties of an object; the
system then does some time consuming calculation and provide a solution
to the user. If the user found the solution unsatisfactory, he/she
could either continue making more changes or undo all changes done
since the previous calculation.

Idea
We were thinking of working with two objects, a shadow object that the
user can go back to and the object that is involved in the calculation.
Now and then in code copy the object with its properties to the shadow
object.

Is this sensible way, does VB.NET have anything to facilitate this, are
there any good alternatives?

I appreciate any comments regarding this dilemma,

Tomas Nordlander

Nov 8 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I would track two variable for each property like so:

Private m_MyProperty as string
Private m_MyPropertyDefault as string

Public Property MyProperty() as String
Get
Return m_MyProperty
End Get
Set (value as string)
m_MyProperty = value
End Set
End Property

Then just set the value of m_MyPropertyDefault to whatever the default
needs to be. Then after the calculations, if the user continues to make
changes just save the new Defaults. Or if the user wants to rollback to
the last defaults call a sub like the following:

Private Sub Rollback()
MyProperty = m_MyPropertyDefualt
' Continue to reset any other properties here
End Sub

Does that make sense?

Thanks,

Seth Rowe
Tomas wrote:
Hi,

I am a VB.NET newbie that would like to know the best practise when
working with objects and undo user changes to objects properties.

Problem
The system allows the user to change properties of an object; the
system then does some time consuming calculation and provide a solution
to the user. If the user found the solution unsatisfactory, he/she
could either continue making more changes or undo all changes done
since the previous calculation.

Idea
We were thinking of working with two objects, a shadow object that the
user can go back to and the object that is involved in the calculation.
Now and then in code copy the object with its properties to the shadow
object.

Is this sensible way, does VB.NET have anything to facilitate this, are
there any good alternatives?

I appreciate any comments regarding this dilemma,

Tomas Nordlander
Nov 8 '06 #2

P: n/a
Thanks Seth, it make sense.

Tomas :)

rowe_newsgroups wrote:
I would track two variable for each property like so:

Private m_MyProperty as string
Private m_MyPropertyDefault as string

Public Property MyProperty() as String
Get
Return m_MyProperty
End Get
Set (value as string)
m_MyProperty = value
End Set
End Property

Then just set the value of m_MyPropertyDefault to whatever the default
needs to be. Then after the calculations, if the user continues to make
changes just save the new Defaults. Or if the user wants to rollback to
the last defaults call a sub like the following:

Private Sub Rollback()
MyProperty = m_MyPropertyDefualt
' Continue to reset any other properties here
End Sub

Does that make sense?

Thanks,

Seth Rowe
Tomas wrote:
Hi,

I am a VB.NET newbie that would like to know the best practise when
working with objects and undo user changes to objects properties.

Problem
The system allows the user to change properties of an object; the
system then does some time consuming calculation and provide a solution
to the user. If the user found the solution unsatisfactory, he/she
could either continue making more changes or undo all changes done
since the previous calculation.

Idea
We were thinking of working with two objects, a shadow object that the
user can go back to and the object that is involved in the calculation.
Now and then in code copy the object with its properties to the shadow
object.

Is this sensible way, does VB.NET have anything to facilitate this, are
there any good alternatives?

I appreciate any comments regarding this dilemma,

Tomas Nordlander
Nov 8 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.