views:

50

answers:

1

I am looking for exemplars (design examples) showing the use of objects (especially abstract base classes and/or interfaces, aka 'protocols' for you smalltalkers) to design a document management architecture in a large Word Processor, Spreadsheet, vector graphic or publishing package, or office-productivity (non-database) application with support for as many of the following as possible:

  • any open source project, will be ideal, and language of implementation is unimportant since I am looking for design examples, however an object oriented language with support for "interfaces" is a must. I know at least a dozen languages, and I'm willing to study any application's source.

  • use of "interface" could loosely be applied to either XPCOM or COM interfaces, or .NET interfaces, or even the use of pure-virtual (virtual+abstract) base-classes for OOP languages that lack the ability to declare an interface distinct from a class.

  • I am mostly looking for a robust, thorough and flexible implementation for a document, IDocument, various document views (IDocumentView), and whatever operations make sense in that case.

  • I am particular interested in cases where the product in question is a real-world product. For example, if anybody familiar with OpenOffice can tell me if the code contains a good sample design.

  • I am looking for design documentation that outlines the design of the interfaces for such an application. So for example, if the openoffice spreadsheet has such an interface design, then that might be the best case, because it is a widely used real-world design, with millions of users, rather than a textbook example, which is minimal, and contrived.

  • I know that the Mozilla platform uses XPCOM, and its design is heavily "interface" oriented, but I am looking more for a "word processor" or "spreadsheet" type of document design, rather than a web-browser.

  • I am particularly interested in the interfaces used to access to data and meta-data such as markup (attributes like bold, and italics, and font size), and the ability to search and look up named entities within a document.

+1  A: 

As it's the model you want to look at then you'll find good, workable and proven models in both Microsoft Office and OpenOffice.

On a smaller scale, there is Java swing, which has a flexible JEditorPane component. It's a flexible framework built on solid abstractions, and provides default implementations that gets into the fine details of the text layout and formatting. It is fundamentally Interface-oriented in the key areas: document model, behaviour and presentation.

  • Document represents the document data, operations on the document and notifications of change. StyledDocument is a subinterface for adding formatting styles to the document contents. Documents are comprised of Elements, which can be arranged in a hierarchy.

  • Actions define behaviour that can be invoked on the model.

  • Views (abstract class) define how to present an Element of the document model. Like elements, views can be hierarchical.

  • An EditorKit ties all of the above together, along with load/save functionality to provide all that is needed to edit a given type of document.

There are default implementations for basic styled documents and HTML documents which are worth looking into to see how things work under the hood. The sources are available for browsing on docjar - or for download (via Mercurial), and are distributed with the JDK.

NetBeans, an IDE built in Java, has a number of different editors. The netbeans editors are built on top of the Swing EditorKit default implementation. Here's a tutorial creating a simple custom editor which can give you insight into how an editor functions and is implemented.

Turning to spreadsheets, the OpenOffice project has an overview of the Spreadshet Document model - there is a corresponding page for text documents - both from the OpenOffice Developers Guide.

That quite a lot of material there, which I hope is relevant and gives you plenty of ideas!

mdma
That's very good. I expect this will get marked as the Answer for this question.
Warren P
I was momentarily confused by all the X Prefixes, in the OO API, and wondered what they meant. Found some overview here:http://api.openoffice.org/docs/DevelopersGuide/Appendix/IDLDesignGuide/IDLDesignGuide.xhtml
Warren P
Well done, thank you.
Warren P