I build multi-document software, each document has its own history list, and every action performed on the document appears in the document's history.

So far everything is fine, the question begins because there are settings that need to be changed globally, such as to create a global 'style' that can be used in some documents.

And there should be an option to undo style creation, and option to change style settings and undo the changes. And option to delete style and undo deletion.

How should I deal with this? I was thinking of doing another history that is global, but it could create a problem in the following case:

  1. The user will create a new style [this will appear in global history]
  2. The user applies the same style to a particular document [this will appear in the private history of the document]
  3. The user returns to global history and wants to undo the style creation.

What's the right way to deal with this?


Another idea:

In the background there will be one global action list, this list will contain all the actions that are done in all documents and also global actions such as style creation.

But the history pane will display a undo list for the active document, this list will actually the global list but filtered, so the user will only see actions that belong to active document and global actions only.

Is this a good idea? Is it possible to implement such a thing in code?

1 Answer 1


This is fundamentally a user experience question. Test this with actual users! From a software engineering standpoint, any approach could be correct here.

  • A solution that might work well in practice would be to add the global operations to the undo list of the most recently active document.
  • Alternatively, consider representing the global resource as its own document with its own undo list. However, creation of a resource is not undoable, you'd need to actively delete it.
  • Show global operations in the undo list, but they might be greyed out when not applicable. The next undo operation would just skip over them.
  • Another very reasonable solution might be to just not offer undo for global operations. This avoids potential implementation problems.

The implicit part of your question is how to deal with dependencies between resources, e.g. where a document resource depends on a particular style resource. Again, there are multiple reasonable approaches:

  • A global resource cannot be deleted while it is referenced by documents. This ensures consistency of your entire data model.
  • A global resource can be unlinked from global access, but would still be referenced by documents. It is only deleted for real when it is no longer referenced.
  • A global resource can be unlinked from global access, in which case a copy will be stored in all documents that reference it.
  • Documents only have a weak reference to the global resource, for example when the resource is only referenced by some name or identifier. If the global resource is deleted, the references from the document can no longer be resolved. In the case of a style resource, this might cause the document to use some default style instead. Depending on the problem domain, an unresolved reference might also be an error. This approach is very common in practice, for example on the World Wide Web or in document databases.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.