473,386 Members | 1,962 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,386 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 3129
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.