posted 6 years ago
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.