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:
 
RWDBTable parts1 = myDbase.table("parts"); //1
RWDBTable parts2 = parts1; //2
parts2.drop(); //3
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:
 
RWDBTable parts = myDbase.table("parts"); //1
RWDBCursor csr1 = parts.cursor(); //2
RWDBCursor csr2 = csr1; //3
csr1.fetchRow(); //4
csr2.fetchRow(); //5
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.
NOTE: 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 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.