In the next release of IBM Open Class library there is to be a high-level framework delivered using the programming model developed by Taligent. A framework is much more than a class library. While a class library is a collection of related classes, a framework is a class library that also embraces design knowledge and provides a running subsystem for a special problem domain. This problem domain may be business related as in accounting, or may be an infrastructure domain, as in compound documents or communication.The programming paradigm is changing with this new technology as shown in Figure 55. The evolution started with the introduction of graphical user interfaces in the 80s. Before the graphical user interfaces, applications were totally in control of the application flow. Reusable code was put in procedural libraries and called by the application.
With the introduction of graphical user interfaces like Mac, OS/2 PM or Windows, the user started to have the control over the program flow by having multiple ways to interact with the applications. The programs consist of an event loop waiting for user interactions.
Figure 55. Evolution Towards FrameworksAn abstract class is a design for a single object. A framework is the design of a set of objects that collaborate to carry out a set of responsibilities. Thus frameworks are larger scale designs than abstract classes. Frameworks are a way to reuse high-level design. Ralph Johnson, Vincent Russo
With a framework, a developer is no longer writing a program that is in control of the application. The framework is the application, which is customized by the developer writing small puzzle pieces of code where he wants to modify the default behavior of the system. It is sometimes called the Hollywood Principle: Don't call us, we will call you. Frameworks can be specialized and modified by subclassing. A framework has the following two interfaces as shown in Figure 56:
° A using interface, which is small and simple to use
° A subclassing interface used to customize the behavior of the framework
Figure 56. FrameworksThe Workplace Shell is an example of an implemented framework. The Workplace Shell controls and owns the process. Other Workplace Shell-based classes written by third parties using WPS objects and classes can be registered and plugged in during run time, inheriting all the functions provided by this framework.
The Compound Document Framework is based on four base classes, a model class, a view class, selection class and a command class as shown in Figure 57. These four classes have to be modified to create a component either for OLE or OpenDoc with this framework. All the other functions such as embedding, linking, drag and drop, undo, scriptability, and interoperability are provided by the framework. The model class is used to define the content of a component the data part. View classes are used to define the user interface. The views are separated from the model very strictly. There may be several views used in parallel by different applications as shown in Figure 58. The Invoice, Accounts receivable and Rolodex application are using different views on the same model Account Info. Account Info has the following three attributes in this example:
° Name/Address
° Phone No.
° Credit Info
If the model, for example the address, changes, all views on this model are notified by the framework, so they can update themselves. The presenter class handles all user interactions.
Figure 57. Compound Document FrameworkWith a view, the user can also make a selection, which specifies a certain range of the model data, for example the address. A selection is very independent from the way it is created. It may be defined by a mouse, keyboard actions, a menu item or a script. These selections can be used to manipulate the model data. A selection is associated with a set of commands specified for this selection to manipulate the specified data. Commands can also be launched in very different ways. It may be done by a menu action, a command line, a mouse event or a script.
Figure 58. Compound Document FrameworkBut commands are always acting on selections and never directly on the model data. The actions performed as command - selection pairs are stored in a history log, thus providing a multi-level undo, implemented by the framework. Because these command - selection classes are independent from the way they were created, the parts get scriptability for free, as shown in Figure 59. The Compound Document Framework, first delivered with Visual Age C++ for Windows and later with the next release for OS/2, can generate OpenDoc components as well as OLE components.
Figure 59. Compound Document Framework