General guidelines for class library designers
One of the most important features of SOM is that it allows you to build
and distribute class libraries in binary form. Because there is no "fragile
base class" problem in SOM, client programs that use your libraries (by
subclassing your classes or by invoking the methods in your classes) will
not need to be recompiled if you later produce a subsequent version of the
library, provided you adhere to some simple restrictions.
- You should always maintain the syntax and the
semantics of your existing interfaces. This means that you cannot take away
any exposed capabilities, nor add or remove arguments for any of your public
methods.
- Always maintain the releaseorder list,
so that it never changes except for additions to the end. The releaseorder
should contain all of your public methods, the one or two methods that
correspond to each public attribute, and a placeholder for each private
method (or private attribute method).
- Assign a higher minorversion number for
each subsequent release of a class, so that client programmers can determine
whether a new feature is present or not. Change the majorversion number
only when you deliberately wish to break binary compatibility. (See the
topic "Modifier statements" in Chapter 4, "SOM IDL and the SOM Compiler"
for explanations of the releaseorder, minorversion and majorversion
modifiers.)
- Under Windows, you should avoid the use of methods
or attributes that return structures. In the DOS/Windows environment, there
is no universally agreed upon calling convention for returning structures
that is observed by all popular language compilers. Instead, define attributes
that return pointers to structures, or define methods that take an out
parameter for passing a structure back to the caller.
Note that you can always avoid this problem in classes of your own design.
However, some of the attributes and methods in the frameworks that come
with the SOMobjects Toolkit do return structures. Many of these are dictated
by the OMG CORBA standard, and could not be avoided. For each of these methods
two common calling conventions have been implemented:
- Microsoft convention, where the address of the structure
is returned in AX:DX, and
- Borland convention, where the caller provides a hidden
first argument to receive a copy of the returned structure.
No
action is needed on your part to use the Microsoft convention. To use the
Borland convention, you should include the file BCCSTRUC.H following any
other "includes" of SOM headers.
5.
With
each new release of your class library, you have significant degrees of
freedom to change much of the implementation detail. You can add to or reorganize
your instance variables, add new public or private methods, inject new base
classes into your class hierarchies, change metaclasses to more derived
ones, and relocate the implementation of methods upward in your class hierarchies.
Provided you always retain the same capabilities and semantics that were
present in your first release, none of these changes will break the client
programs that use your libraries.
[Back: Creating a SOM Class Library]
[Next: Types of class libraries]