• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Logging user actions and allow undo/redo operations

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am looking for a tutorial or a book on designing loging system with undo/redo options.

Consider GItHub. It has users with pull/push powers. It has admins capable of creating/modifying/deleting users.

I am designing a program for document storage. Roles include Principle, Admins and Users. Users can create and modify documents, Admins can modify user privileges and ownership of documents. Principle can create/delete admins.

When an admin creates a `String userID = Joe_Dow;` we execute a statement like:   `INSERT INTO Users (ID) VALUES ('" + userID + " ')`
We can also write `UserID + " was created\n";` to a log file. What I don't understand is how to save those as reversible actions with undo/redo, rather than a plain text. One can try to save SQL statements, but that wouldn't work. For instance:

(1) UserID FooBar created
(2) FooBar added edited message of JoeDoe
(3) FooBar promoted to an Admin
(4) FooBar account was deleted

Now we want to undo last action. Does it mean "repeat steps 1-3"? What if JoeDoe message was already deleted and step 2 cannot be done?

Should one design an reverse operation for every action and record it in a BackForwardLog

EventID ForwardOperation     UndoOperation
3       delete User FooBar   Create user name: "FooBar", privileges : ["Admin"]  

I am not looking for a technical answer to a specific question. Rather, recommendations for what to keep in mind when designing such systems.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I remember one pattern for this is to have objects that have execute() and rollback() functionality. So an "add" would have insert in execute and delete in rollback. This lets you have lists of such objects and undo/redo up/down the list.
 
reply
    Bookmark Topic Watch Topic
  • New Topic