473,287 Members | 1,674 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,287 software developers and data experts.

Object Transaction / Class Transaction Undo Without Database

Dear ladies and gents,

I'm trying to determine whether the .NET Framework implements a means
of transactional processing without the need for a database.
Essentially, I'd like to enlist light-weight portable business objects
within transactions so that that have the ability to roll-back if the
client of the object wishes to undo any changes made. For example, if I
had a, let's say for sake of simplicity, a person class that had two
public properties, Forename and Surname. If the user changes both
Forename and Surname then wishes to cancel those changes (meaning that
the object will return to it's original state (before the user modified
the object by means of either of the properties)) they could do by
invoking a method (such as 'Undo').

E.g.

Original values (before user interaction)
============================
personInstance.Forename is equal to "Joe"
personInstance.Surname is equal to "Bloggs" (surprise, surprise, I bet
no one saw that coming)...
Then the user modifies the Forename and Surname...
=========================================
personInstance.Forename = "John";
personInstance.Surname = "Smith";
The user then realises that the modifications he/she/it made needs to
be undone, for whatever reason...

The user could then invoke a method such as ...

personInstance.Undo();

The object would then undo all changes made so that all data would
reflect the the object state before the user modified it.
Data after undo...
=============
personInstance.Forename is equal to "Joe"
personInstance.Surname is equal to "Bloggs" (surprise, surprise, I bet
no one saw that coming)...
My current intention is to create deep copies of the object and pass
copies to the clients, let them update the copies and if all is well
(i.e. an undo is not required) then the copy of the object would then
replace the original. Otherwise, the copy object would be discarded
(effectively appearing as an undo operation)...
Please would a kind person, or not so kind (if that is how you prefer
to be perceived) offer some light on whether transactions can be used
quickly and easily to achieve the abovementioned task, or whether my
approach is a bad/good approach/whether there is a better and simpler
way.
Many thanks for taking the time to read this.
Have a nice day,

Craig.

Oct 25 '06 #1
3 3122
Hi Craig

You might want to have a look at this:
http://www.dofactory.com/Patterns/PatternMemento.aspx

Its a simple undo pattern.

Sam

Oct 25 '06 #2


I concur. The Memento Pattern is the way to go for "Undo's".
"samuelhon" <sa****@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
Hi Craig

You might want to have a look at this:
http://www.dofactory.com/Patterns/PatternMemento.aspx

Its a simple undo pattern.

Sam

Oct 25 '06 #3
Hi Craig,

You can use COM+ services in managed code for transaction support just like
you always have in COM.

ServicedComponent on MSDN:
http://msdn2.microsoft.com/en-us/lib...component.aspx

In the 2.0 framework there is a new namespace as well:

System.Transactions

It contains managed classes that provide transaction processing support for
local and distributed transactions. For instance, you can use the
TransactionScope class to enlist a System.Data.IDbConnection into a managed
transaction without explicitly using an implementation of IDbTransaction.

TransactionScope class on MSDN:
http://msdn2.microsoft.com/en-us/lib...tionscope.aspx

Using transactions along with commands (or mementos as another respondant
suggested) can make undo/redo operations transparent in code by encapsulating
the commit/rollback logic in separate components.

You can create a singleton in your application that will allow any caller to
undo the last operation, redo the previous operation or cancel the current
operation all by storing a current operation context. In my applications I
use a stack to implement the undo/redo context.

--
Dave Sexton

"GoogleEyeJoe" <cr*****@hotmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
Dear ladies and gents,

I'm trying to determine whether the .NET Framework implements a means
of transactional processing without the need for a database.
Essentially, I'd like to enlist light-weight portable business objects
within transactions so that that have the ability to roll-back if the
client of the object wishes to undo any changes made. For example, if I
had a, let's say for sake of simplicity, a person class that had two
public properties, Forename and Surname. If the user changes both
Forename and Surname then wishes to cancel those changes (meaning that
the object will return to it's original state (before the user modified
the object by means of either of the properties)) they could do by
invoking a method (such as 'Undo').

E.g.

Original values (before user interaction)
============================
personInstance.Forename is equal to "Joe"
personInstance.Surname is equal to "Bloggs" (surprise, surprise, I bet
no one saw that coming)...
Then the user modifies the Forename and Surname...
=========================================
personInstance.Forename = "John";
personInstance.Surname = "Smith";
The user then realises that the modifications he/she/it made needs to
be undone, for whatever reason...

The user could then invoke a method such as ...

personInstance.Undo();

The object would then undo all changes made so that all data would
reflect the the object state before the user modified it.
Data after undo...
=============
personInstance.Forename is equal to "Joe"
personInstance.Surname is equal to "Bloggs" (surprise, surprise, I bet
no one saw that coming)...
My current intention is to create deep copies of the object and pass
copies to the clients, let them update the copies and if all is well
(i.e. an undo is not required) then the copy of the object would then
replace the original. Otherwise, the copy object would be discarded
(effectively appearing as an undo operation)...
Please would a kind person, or not so kind (if that is how you prefer
to be perceived) offer some light on whether transactions can be used
quickly and easily to achieve the abovementioned task, or whether my
approach is a bad/good approach/whether there is a better and simpler
way.
Many thanks for taking the time to read this.
Have a nice day,

Craig.

Oct 25 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Frank Millman | last post by:
Hi all I have a question regarding inheritance. I have come up with a solution, but it is not very elegant - I am sure there is a more pythonic approach. Assume the following class definitions....
0
by: xo55ox | last post by:
Hi, I have been trying to set up an automated restore process from prod to backup server. First, I schedule the full database backup nightly, transfer the backup file and restore it to the...
13
by: Patrick | last post by:
I understand that with IIS5.1 on Windows XP Professional SP1, I can 1) Either set under IIS Manager-> Any specific Virtual Directory-> Configuration->Options->ASP Script timeout for all pages...
1
by: Avanish Pandey | last post by:
Hello All We have 3 differen services (in 3 different server) Service A,B,C . We want to implement distributed transaction when call methods of B and C from A. Is it possible? if yes then how? ...
0
by: rein.petersen | last post by:
Hi All, Some of you may have encountered complications when trying to serialize an object derived from CollectionBase (implementing ICollection or IEnumerable). Specifically, the...
16
by: ed_p | last post by:
Hello, I have implemented the singleton pattern for a class to hold a SqlConnection object that will be used thruout the application to create commands. My application is a simple Windows Form...
5
by: Louis LeBlanc | last post by:
Hey folks. I'm new to the list, and not quite what you'd call a DB Guru, so please be patient with me. I'm afraid the lead up here is a bit verbose . . . I am working on an application that...
2
by: David Jessee | last post by:
I've been taking this approach when working with business entity objects: 1) Determine the ID of the object you need to work with (e.g. Invoice) 2) Get the Object instance of the Invoice...has a...
8
by: =?Utf-8?B?UmF2aQ==?= | last post by:
Hi, I'm trying to pass values of different data-types to a web-service. I thought it would be easier to box these values and pass them as a System.object parameter, like public void...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...

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.