Archives
 
 
 
  Special
 
 
 
  About Us
 
 
 

Newsletter
Free E-mail Newsletter from BYTE.com

 
    
           
Visit the home page Browse the four-year online archive Download platform-neutral CPU/FPU benchmarks Find information for advertisers, authors, vendors, subscribers Request free information on products written about or advertised in BYTE Submit a press release, or scan recent announcements Talk with BYTE's staff and readers about products and technologies

ArticlesTo Inherit or Not to Inherit?


January 1994 / Special Report / To Inherit or Not to Inherit?

The ability of objects to be derived from and specialize more general objects is fundamental to any object-oriented system. Yet Microsoft deliberately excluded inheritance from OLE 2.0's object model. The problem, according to OLE developers, is that it's hard to specify a precise interface between a base object and a derived one.

For example, suppose an object inherits half of its behavior from the operating system and provides the other half itself. Now suppose that a new version of the operating system revises the base object while preserving its interface. In theory, the derived object should still work perfectly. This is the major selling point for object-oriented systems. IBM, for example, touts SOM (System Object Model) as a way to achieve binary reuse of objects.

But there can be hidden pitfalls, s ay OLE developers. Suppose the derived object defines a virtual method that supersedes a method in the base object. Suppose also that the original version of the base object called this virtual method once after all its data was initialized. What if the new base object called the virtual method before some piece of data was initialized? The interface wouldn't be violated--parameters would still be passed correctly--but tacit assumptions made by the derived object's programmer could lead to trouble.

Microsoft therefore came up with the notion of aggregation, whereby programmers must explicitly build in the pointers from a derived object to a base object. This approach allows the programmer to build in controls that would stop the object from inheriting something in a dangerous way. The programmer could, for example, force the derived object to check the revision number of the base object.

In IBM's SOM, on the other hand, the dispatcher automatically uses the first instance of a base-class object that it can find. This approach requires more discipline on the part of programmers, who must try to ensure that the derived code they write interacts with base-class objects from one revision to another.

Apple's Kurt Piersol is familiar with this dilemma, because OpenDoc's object model is SOM. He believes, however, that talented programmers deserve the freedom that inheritance brings and can handle the responsibility that it demands. Jim Green, director of the DOE (Distributed Objects Everywhere) project at Sun Microsystems, agrees, and he notes that Microsoft's is the only object system that imposes such strictness.

Who's right? Only time will tell. Objects are not standard equipment yet. When there's a broader base of experience, we'll see whether programmers will run amok with inheritance and come begging for forgiveness like the prodigal son.


Up to the Special Report section contentsGo to previous article: Objects on the MarchGo to next article: Personality PlusSearchSend a comment on this articleSubscribe to BYTE or BYTE on CD-ROM  
Flexible C++
Matthew Wilson
My approach to software engineering is far more pragmatic than it is theoretical--and no language better exemplifies this than C++.

more...

BYTE Digest

BYTE Digest editors every month analyze and evaluate the best articles from Information Week, EE Times, Dr. Dobb's Journal, Network Computing, Sys Admin, and dozens of other CMP publications—bringing you critical news and information about wireless communication, computer security, software development, embedded systems, and more!

Find out more

BYTE.com Store

BYTE CD-ROM
NOW, on one CD-ROM, you can instantly access more than 8 years of BYTE.
 
The Best of BYTE Volume 1: Programming Languages
The Best of BYTE
Volume 1: Programming Languages
In this issue of Best of BYTE, we bring together some of the leading programming language designers and implementors...

Copyright © 2005 CMP Media LLC, Privacy Policy, Your California Privacy rights, Terms of Service
Site comments: webmaster@byte.com
SDMG Web Sites: BYTE.com, C/C++ Users Journal, Dr. Dobb's Journal, MSDN Magazine, New Architect, SD Expo, SD Magazine, Sys Admin, The Perl Journal, UnixReview.com, Windows Developer Network