From: Brian Candler Date: 2003-05-01T06:29:42+09:00 Subject: Re: [OO interface design] Pass-by reference VS encapsulation ? On Thu, May 01, 2003 at 05:37:46AM +0900, ahoward wrote: > alternatively, you could implement a module which enfores RI for mutable > methods and extend any contact added to an addresssbook with this module - > contacts outside of an addressbook do not need RI after all. That's a very cool idea. Since the RI methods are in the object's singleton class, doing a '.dup' will give you a fresh object without the RI methods - in otherwords it copies a contact which is 'bound' into the addressbook and gives you another object which is 'free'. I am not sure about allowing one contact object to be shared between two addressbooks though. Any change to the contact would have to be 'agreed' by both addressbooks, which sounds like a fairly complicated two-phase commit to avoid getting into an inconsistent state. In the end it may be simpler to take a copy and check it back into the addressbook(s) after any changes have been made. Sort of like having a 'post-it note' onto which you scribble the details, and then write them back after editing. It involves data copying but it's how things would work if you were using a distributed system like DRuby anyway. Regards, Brian.