Use special names for copy, create, and adopt routines

Routines that allocate, manage, or take responsibility for storage have special names and abide by the following guidelines:

Routines that make a new object that the caller must delete begin with Create...

Routines that copy an existing object, where the caller must delete the copy, begin with Copy... A member function that copies an object should be Copy().

Routines that abandon an object and pass deletion responsibility to the caller begin
with Orphan...

Routines that accept an object the caller has allocated and take responsibility for eventually deleting it begin with Adopt... (This style of programming is error prone; avoid it
if possible.)

Adopting routines that cannot follow the previous rule (such as constructors) start the name of the argument with adopt...


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker