[Contents] [Previous] [Next]

A classic application framework

MacApp, from Apple Computer, was one of the first commercially successful application frameworks. It provides working code for a generic Mac OS application, which is not easy to write from scratch. The generic application is built from objects, so MacApp programming involves using object-oriented techniques even though the objects are implemented on top of a procedural operating system. The generic application includes a working menu system that takes care of pulling down menus, highlighting, dimming items that aren't active, implementing command-key equivalents, and so on. It also includes standard File and Edit menus.

The File menu includes working New, Open, Close, Save, and Save As commands and the dialog boxes for locating files and disks that go with them. The File menu also includes the Print and Page Setup commands, with the corresponding code for printing multiple copies on various sizes of paper, portrait or landscape orientation, and so on. The last default command in the File menu is the Quit command, for exiting the program.

The Edit menu includes Cut, Copy, Paste, and Undo, all supported by "boilerplate" code--that is, the code that sets up and runs the commands, with stubs for the code to be provided by a specific application.

A programmer doesn't have to write any of these menu commands from scratch. They're working and ready to use, although in some cases they can't really do much without additional application-specific code. To make an application do anything useful, it's necessary to override at least some of the application framework's member functions.

For example, if you're writing a drawing application using MacApp, you need to add only the additional parts that give the application its drawing capabilities; you can use everything else as is. You would add a Tools menu for the graphic objects your program can draw and pieces of code that determine what each tool in that menu does when the user chooses the tool and moves or clicks the mouse within a window. You would also override MacApp's boilerplate code for the data your program reads and writes when the user opens, closes, and saves files, replacing it with code that can read and write the actual data for the graphics objects your program knows about. By just subclassing and overriding these few parts of the MacApp framework, you can create a complete, well-behaved drawing application with much less effort than it would take to create it without the framework.


[Contents] [Previous] [Next]

Addison-Wesley Publishing Company, Copyright©1995 by Sean Cotter and Taligent,Inc. All rights reserved.