473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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

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
2 1950
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
0
by: Damien Anselmi | last post by:
I am using the CompileAssemblyFromSource method of an ICodeCompiler instance to dynamically compile an assembly used by a Web Application. The assembly may be recompiled any number of times during...
2
by: Bob | last post by:
Cannot copy assembly '<...>' to file <...>.dll'. The process cannot access the file because it is being used by another process. Could not copy temporary files to the output directory. The file...
3
by: Marc Gravell | last post by:
Kind of an open question on best-practice for smart-client design. I'd really appreciate anyones views (preferably with reasoning, but I'll take what I get...). Or if anybody has any useful links...
2
by: Diffident | last post by:
Hello All, I just finished reading an interesting article by Scott about App Domains: http://odetocode.com/Articles/305.aspx Scott, I have a question about the section "Shadow Copies and...
17
by: Steve | last post by:
I'm trying to code cut, copy, and paste in vb 2005 so that when the user clicks on a toolbar button, the cut/copy/paste will work with whatever textbox the cursor is current located in (I have...
9
by: CMM | last post by:
I've been scouring the net for the last few days looking for a way to copy a locked file (create a shadow volume, expose it... that's it) from within my program. I'm aware of the kludgy vshadow.exe...
19
by: Daniel Pitts | last post by:
I have std::vector<Base *bases; I'd like to do something like: std::for_each(bases.begin(), bases.end(), operator delete); Is it possible without writing an adapter? Is there a better way? Is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.