TweetFollow Us on Twitter

July 93 - OOPC

OOPC

Gary Odom

OOPC is a full source code software development toolkit. OOPC has two components: an object system that turns standard C into a dynamic object-oriented programming language, and an application development framework to accelerate application development. This article tells why OOPC was created (its design goals), and in doing so provides a description of OOPC's feature set.

The Macintosh version of OOPC has been shipping since August, 1992, and is currently at version 1.3. A Windows version is going to be available before the end of 1993. OOPC's API (application programming interface) is already platform-independent.

Object System

OOPC's object system was designed to allow flexible object-oriented programming in C. The OOPC object system was created in 1988 for an artificial intelligence program. The specific design goals of OOPC's object system, all of which were achieved, were as follows.
  • Standard C syntax that works on any C compiler.
  • Multiple inheritance.
  • Dynamic definition of inheritance and method attachment, where classes and objects are completely defined (and can be modified) at run-time.
  • Fast execution speed.
  • Flexible usage of classes and objects: allowing a class to have its own data, separate from the objects it creates; and allowing object methods (separate from the class an object inherits from).
  • Enforce a simple API.
  • Provide dispatch control (before- and after-methods) that maximize code reusability.
  • Provide an abstraction mechanism for subsystem processing (which classes do not provide).
  • Garbage collection and support for object linkage (necessary for both garbage collection and OODB).
  • Provide support for collections, which are integral to OOP.

There is a common myth that an object system requires compiler support. Most object systems are implemented using a new language (such as Dylan), or an extension to an existing language (CLOS, C++), which require a new compiler (or at least a preprocessor), but this results from a design decision to create or modify existing language syntax, or simply to implement the object system using a compiler. People who design object systems are often computer language junkies and compiler writers; people who are biased to think in terms of "advances" in syntax, which require a new compiler. C++ is a perfect example of such tinkering. OOPC fully implements dynamic object-oriented programming without requiring special preprocessing or compiler implementation.

There is a trend in object-oriented programming products towards flashy development environments, with slinky linkers that slip patch code in without having to quit running an application in a debugging session, or other frilly features that "give great demo." That was never on the goal agenda for OOPC. OOPC is a simple-but-sophisticated, meat-and-potatoes code library. OOPC works with any C compiler. This approach keeps Electron Mining's development efforts focused on providing leverage for its customers, to accelerate their application development, not on spinning marketing flash (or trying to rope people into a proprietary development environment).

Most advanced object systems take their inspiration from CLOS, as does OOPC. CLOS provides dynamic definition of class-objects, and the use of generic functions to enforce a simple API.

OOPC uses verb functions, which are the same concept as CLOS's generic functions. (The term verb is used to emphasize the concept of verb-object action. Generic seemed too nondescriptive.) Any object is drawn using draw, or acted upon using act. Different verbs may dispatch to the same method. Often, the same method is used to draw or print an object; only a few classes have objects that print differently than they draw. Thus, using verb functions both simplifies the API and makes it consistent, and provides a means for greater code reuse while doing so. The verb set is extensible.

Before-methods and after-methods provide dispatch control, minimize dispatch overhead (by dispatching to two methods in a single call), and maximize code reuse (by allowing selective method overriding). OOPC also implements the concept of middle-methods, where dispatch can continue from inside a method (using continue_dispatch). Dispatch can also be targeted to a specific method (using dispatch_to).

OOPC dispatch is table driven, making it very fast. A verb is actually an index into a method table, masquerading as a function call. Methods can be defined or changed any time during program execution. Dynamic definition allows all aspects of object orientation to be defined and modified at run-time. The effect on flexibility with regard to design and implementation is profound.

A simple example of dynamic inheritance: while reading in a dialog item resource for a file, create dialog item objects, then add the right class (control, picture, text, and so on) to a dialog item once the item type is discovered (by reading the dialog item resource data). This can be done in a static OOP language by not assigning the dialog item type class before reading the dialog item resource definition, but that involves processing in a way dictated by the language's limitations, rather than doing things the way that might first come to mind (which is usually the most straight-forward way) if no constraints were imposed. The flexibility of a dynamic object system brings both small and large benefits.

Object orientation with OOPC is achieved using a small set of functions. new_class is used to create a class. new_object creates an object. define_method associates a verb function with a specific method. set_method_flag sets a before- or after-method status for a method.

OOPC implements the concept of agents. An agent is a subsystem of processing. There are agents for overall application processing (startup, quit), events handling, printing (page setup, print job, printing), cursor control, and menu/menu item enabling/disabling. An agent is associated with a class, but provides a mechanism to encapsulate processing and allow processing modification, much as a class encapsulates object data and behavior.

OOPC's object system has built-in support of object linkage. Objects can be linked to one another. This has two purposes. First, in a software world of self-contained modularity, object links are essential for object interaction. A tear-off menu, for example, is a cooperative effort between a menu, a window actor, a view, one or more lists, and a picture of the view (for rapid drawing of the view for the menu). Having an object system that has object linkage support built in facilitates setting up component software interaction. Second, object links are used for garbage collection; specifically, to make sure an object isn't freed if any other objects are using it.

Maintaining collections is an essential aspect of object-oriented programming. A document is a collection of pages. A view is a collection of objects that appear in the view. A menu bar is a collection of menus, each of which is a collection of menu items. The OOPC object system has efficient functions for maintaining collections.

Application Framework

The design goals of the application framework were as follows.
  • A streamlined class library architecture for simplified learning and maintenance.
  • Full user interface feature set.
  • Simple but sophisticated rule-based activity control.
  • Automatic document management.
  • Data management.
  • Built-in object persistence that can be applied to new classes with little or no additional code.
  • Multiple-priority event processing, include threading.
  • Accelerated memory management optimized for a large number of blocks.
  • Comprehensive, sophisticated exception handling.
  • Good debugging tools.
  • Object-oriented graphics package.
  • A universal language styled text engine.
  • Platform independence.

The architecture of the OOPC class library revolves around actors. A document is a type of actor, as are dialogs. Actors are at the top of the activity hierarchy. Actors handle window events, because actor objects own window objects.

What happens when a user clicks on an object within the content region of a window? The EventAgent tells the actor that an event has occurred in the window owned by it. The EventAgent calls the actor to act. The actor looks to its window, which holds the window's view(s). A view holds a collection of objects that are visible in the window. Windows have at least one view. The actor looks through the objects in its view(s) until it finds the object sitting where the mouse was clicked, then calls that object to act upon itself.

An actor manages its window and the objects that appear in the window. Visually, an actor controls window display. A window draws the views in itself. Each view draws the objects in itself. A document uses the concept of pages. Each page manages display of its own view in the document window. A document manages pages, and adds a new object to itself by adding it to its current page.

MacApp, which is view-happy, requires that every object in a view belongs to a view subclass. OOPC suffers no such architectural nonsense. An OOPC view is simply a container for a collection of objects that has its own coordinate system. Views can be selected for onscreen or offscreen drawing (if the view has an offscreen bitmap).

OOPC 1.3 has three document classes, all of which handle multiple-page documents. cDocument handles documents where the pages appear one after another vertically, as with a word processor. cPoster provides a large, poster-sized document, such as those used in drawing programs. cRecordDoc implements the database record model, where only one page/record is visible at a time. There is also a list actor class that can be put into use for spreadsheet documents. Acting, drawing, printing, undo and scrap operations are handled automatically.

OOPC's class library provides a full set of user interface features. In addition to the classes you would expect, tear-off menus, floating windows, tool, pattern and color palette classes are also provided. All modal dialogs are automatically movable modals, even under System 6. User interaction with standard dialog item types (controls, editable text) is handled automatically. OOPC provides a MultiFinder/System 7 type DA menu bar for any user running under the System 6 Finder.

OOPC controls are platform-independent. New control types can be easily implemented, requiring only a draw method override for simple controls, and an act method for more complex control types.

There is a rule class, used for activity control, and appropriate for building rule-based systems. Cursor and menu activation are controlled using rule objects. Rules can be merged using AND or OR joins to build a rule framework object.

OOPC has a sophisticated multiple-priority event processing agent. There are multiple event queues, each at a different priority. The OS event queue is a mid-priority queue. Handling for any type of operating system event can be modified with a single call to an EventAgent modifier. There is a timer event queue for periodic events. The number of event queues is extensible (by adding one or more constant definitions in the event header file). Threaded processing is accomplished by creating new events of the needed priority. Events can be controlled in any event queue, including operating system events.

OOPC has its own pointer-based memory management system. Figure 1 shows the results of timing studies on Mac OS and OOPC memory management. Large blocks are taken from the operating system and cut into smaller slices, which are for object-related data storage. The Jan/Feb 93 FrameWorks has an article detailing OOPC memory management.

OOPC has a simple exception handling mechanism that is used throughout the class library. Normal execution code is placed between CODE and HANDLER macro statements. Exception handling code, which cleans up by deallocating memory allocated during normal execution (and optionally sets an alert message), is located between HANDLER and CONTINUE_HANDLER statements. (CODE {normal execution code} HANDLER {exception handling code} CONTINUE_HANDLER). CONTINUE_HANDLER sends program execution up the stack frame to the calling method, so clean-up can occur through the call chain. END_HANDLER, which can be used instead of CONTINUE_HANDLER, terminates the jumping up the stack frame (thereby terminating the exception handling process). Exception handlers can be nested.

Error reporting is automatic. A variety of error reporting alerts are provided. The application agent reports errors during initialization, and the event agent reports errors while handling events. (The event agent manages all event handling, so is at the top of the call chain while an application is running.)

OOPC 1.3 comes with a fully interactive class browser and object inspector. Figure 2 shows the browser. Any data area that shows a class, object, or array of objects or methods is an active field that can be clicked on to bring up an inspector window.

The class browser is helpful in both learning OOPC, and for debugging. OOPC also has another valuable debugging tool: execution trace debug files which can be created during a debugging session at the switch of a compile option. A wrong or out-of-order processing call is a common cause of problems with object-oriented programming. An execution trace file is extremely helpful in fixing such a problem. Also, class methods consistently use data checking with exception handling to minimize the introduction of bugs during development and facilitate rapid debugging.

For data management, OOPC provides a variety of collection, array and list classes. There are classes for unordered collections, queues and stacks. There are bit array and variable-sized data array classes. OOPC has a list class that supports variable-sized rows and columns. The class browser shown in Figure 2 uses a subclass of the basic list actor class.

OOPC includes both paint and graphic object classes. Pictures, icons, and a full complement of geometric shapes are provided.

A text engine is currently under development. OOPC currently has a styled text class that uses the Macintosh Toolbox TextEdit. The next major version of OOPC will sport a powerful text engine that fits the bill for platform-independence. Along with the text engine will come a cTextDoc class that handles text editor document operations.

OOPC's API is already platform-independent. The release of OOPC for Windows in late 1993 will be proof of the pudding.

Conclusion

OOPC's object system was designed to yield maximum object-oriented flexibility and power using standard C, and enforce a simple, consistent API. OOPC's application framework was created to provide extensive support for accelerating development for a wide range of application types and needs. Four years old and already a mature product, OOPC class library development is ongoing in an effort to broaden its scope, providing further acceleration for application developers.
 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

The secrets of Penacony might soon come...
Version 2.2 of Honkai: Star Rail is on the horizon and brings the culmination of the Penacony adventure after quite the escalation in the latest story quests. To help you through this new expansion is the introduction of two powerful new... | Read more »
The Legend of Heroes: Trails of Cold Ste...
I adore game series that have connecting lore and stories, which of course means the Legend of Heroes is very dear to me, Trails lore has been building for two decades. Excitedly, the next stage is upon us as Userjoy has announced the upcoming... | Read more »
Go from lowly lizard to wicked Wyvern in...
Do you like questing, and do you like dragons? If not then boy is this not the announcement for you, as Loongcheer Game has unveiled Quest Dragon: Idle Mobile Game. Yes, it is amazing Square Enix hasn’t sued them for copyright infringement, but... | Read more »
Aether Gazer unveils Chapter 16 of its m...
After a bit of maintenance, Aether Gazer has released Chapter 16 of its main storyline, titled Night Parade of the Beasts. This big update brings a new character, a special outfit, some special limited-time events, and, of course, an engaging... | Read more »
Challenge those pesky wyverns to a dance...
After recently having you do battle against your foes by wildly flailing Hello Kitty and friends at them, GungHo Online has whipped out another surprising collaboration for Puzzle & Dragons. It is now time to beat your opponents by cha-cha... | Read more »
Pack a magnifying glass and practice you...
Somehow it has already been a year since Torchlight: Infinite launched, and XD Games is celebrating by blending in what sounds like a truly fantastic new update. Fans of Cthulhu rejoice, as Whispering Mist brings some horror elements, and tests... | Read more »
Summon your guild and prepare for war in...
Netmarble is making some pretty big moves with their latest update for Seven Knights Idle Adventure, with a bunch of interesting additions. Two new heroes enter the battle, there are events and bosses abound, and perhaps most interesting, a huge... | Read more »
Make the passage of time your plaything...
While some of us are still waiting for a chance to get our hands on Ash Prime - yes, don’t remind me I could currently buy him this month I’m barely hanging on - Digital Extremes has announced its next anticipated Prime Form for Warframe. Starting... | Read more »
If you can find it and fit through the d...
The holy trinity of amazing company names have come together, to release their equally amazing and adorable mobile game, Hamster Inn. Published by HyperBeard Games, and co-developed by Mum Not Proud and Little Sasquatch Studios, it's time to... | Read more »
Amikin Survival opens for pre-orders on...
Join me on the wonderful trip down the inspiration rabbit hole; much as Palworld seemingly “borrowed” many aspects from the hit Pokemon franchise, it is time for the heavily armed animal survival to also spawn some illegitimate children as Helio... | Read more »

Price Scanner via MacPrices.net

Apple’s 13-inch M2 MacBook Airs return to rec...
Apple retailers have 13″ MacBook Airs with M2 CPUs in stock and on sale this weekend starting at only $849 in Space Gray, Silver, Starlight, and Midnight colors. These are the lowest prices currently... Read more
Best Buy is clearing out iPad Airs for up to...
In advance of next week’s probably release of new and updated iPad Airs, Best Buy has 10.9″ M1 WiFi iPad Airs on record-low sale prices for up to $200 off Apple’s MSRP, starting at $399. Sale prices... Read more
Every version of Apple Pencil is on sale toda...
Best Buy has all Apple Pencils on sale today for $79, ranging up to 39% off MSRP for some models. Sale prices for online orders only, in-store prices may vary. Order online and choose free shipping... Read more
Sunday Sale: Apple Studio Display with Standa...
Amazon has the standard-glass Apple Studio Display on sale for $300 off MSRP for a limited time. Shipping is free: – Studio Display (Standard glass): $1299.97 $300 off MSRP For the latest prices and... Read more
Apple is offering significant discounts on 16...
Apple has a full line of 16″ M3 Pro and M3 Max MacBook Pros available, Certified Refurbished, starting at $2119 and ranging up to $600 off MSRP. Each model features a new outer case, shipping is free... Read more
Apple HomePods on sale for $30-$50 off MSRP t...
Best Buy is offering a $30-$50 discount on Apple HomePods this weekend on their online store. The HomePod mini is on sale for $69.99, $30 off MSRP, while Best Buy has the full-size HomePod on sale... Read more
Limited-time sale: 13-inch M3 MacBook Airs fo...
Amazon has the base 13″ M3 MacBook Air (8GB/256GB) in stock and on sale for a limited time for $989 shipped. That’s $110 off MSRP, and it’s the lowest price we’ve seen so far for an M3-powered... Read more
13-inch M2 MacBook Airs in stock today at App...
Apple has 13″ M2 MacBook Airs available for only $849 today in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty is included,... Read more
New today at Apple: Series 9 Watches availabl...
Apple is now offering Certified Refurbished Apple Watch Series 9 models on their online store for up to $80 off MSRP, starting at $339. Each Watch includes Apple’s standard one-year warranty, a new... Read more
The latest Apple iPhone deals from wireless c...
We’ve updated our iPhone Price Tracker with the latest carrier deals on Apple’s iPhone 15 family of smartphones as well as previous models including the iPhone 14, 13, 12, 11, and SE. Use our price... Read more

Jobs Board

Licensed Practical Nurse - Womens Imaging *A...
Licensed Practical Nurse - Womens Imaging Apple Hill - PRN Location: York Hospital, York, PA Schedule: PRN/Per Diem Sign-On Bonus Eligible Remote/Hybrid Regular Read more
DMR Technician - *Apple* /iOS Systems - Haml...
…relevant point-of-need technology self-help aids are available as appropriate. ** Apple Systems Administration** **:** Develops solutions for supporting, deploying, Read more
Operating Room Assistant - *Apple* Hill Sur...
Operating Room Assistant - Apple Hill Surgical Center - Day Location: WellSpan Health, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Read more
Solutions Engineer - *Apple* - SHI (United...
**Job Summary** An Apple Solution Engineer's primary role is tosupport SHI customers in their efforts to select, deploy, and manage Apple operating systems and Read more
DMR Technician - *Apple* /iOS Systems - Haml...
…relevant point-of-need technology self-help aids are available as appropriate. ** Apple Systems Administration** **:** Develops solutions for supporting, deploying, Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.