When should I make my class a big object class? Why?

(from an email from Charles Galambos)

Basic Reasons:

  1. It's a way of managing memory, freeing it only when all pointers are removed. In this role it avoids a lot of the problems with accessing freed memory and memory leaks.
  2. Like using pointers - it allows you to pass around large objects as a pointer instead of doing lots of copying.
  3. There are also some side benefits when overriding operators on a class. It allows you to define arithmetic operators on your class which is dangerous or impossible with pointers as it conflicts with the build in type operators.
  4. It gives a clear boundary between the implementation of the class's functionality and the interface the user is expected to use. Though only a conceptual advantage, it helps significantly in larger programs.
This means:

Hints and tips:

Writing big objects:

The easiest way to write a big object is to derive the body from BodyRefCounterC and then the handle for RCHandleC. This automatically provides all the functionality you need.

There is also a program called doClassWizard which will write a skeleton big object class for you. You can then edit this to your requirements. Try doClassWizard -class MyClass and have a look in the directory ./MyClass. You should be able to compile the code in this directory with the command am (NB: due to a minor bug this is not true at the moment.)


Bill Christmas
Last modified: Thu Jul 1 10:52:00 BST 1999