Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
DB Interface Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

2.4 Reference Semantics

While designing the DB Interface Module, we were faced with deciding whether its classes should obey value semantics or reference semantics. Generally speaking, classes that obey value semantics are easier to understand, while those that obey reference semantics are more efficient. Database programming raises other considerations, as in the following code:

Here value semantics would be impossible to implement sensibly. The RWDBTable instances refer to a physical object that resides outside the program domain, the parts table in the database. It makes sense that when we drop the parts2 table on //3, the parts1 object created on //1 is also affected. Here is a more subtle example:

Value semantics dictate that the fetches on //4 and //5 each retrieve the first row of the "parts" table; reference semantics dictate that //4 fetches the first row while //5 fetches the second. In this example, there is a sensible interpretation of value semantics, though we guess that most database programmers would find that interpretation counter-intuitive. In any case, we believe that the most confusing situation of all would be to freely mix value and reference semantics, so we use reference semantics throughout the DB Interface Module.


With rare exceptions, classes of the DB Interface Module obey reference semantics. Copy constructors and assignment operators result in interface objects that share a common implementation.

The exceptions to this design are the concrete class RWDBValue and the concrete data types RWDBDateTime (deprecated), RWDateTime, RWDBDuration, RWDecimalPortable, RWDBBlob, RWCString, RWDBMBString, RWWString, and RWBasicUString. The last five use the copy on write technique as a compromise between efficiency and easy-to-understand semantics; the others are simply copied bitwise. RWDecimalPortable, RWDateTime, RWCString, RWWString, and RWBasicUString are classes of the Essential Tools Module used by the DB Interface Module.



Previous fileTop of DocumentContentsIndex pageNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.