From: Dave Thomas Date: 2003-05-01T22:12:51+09:00 Subject: Re: [OO interface design] Pass-by reference VS encapsulation ? Simon Vandemoortele wrote: > Something like this ? > > c = myAddressbook.getContact('Simon Vandemoortele') > > c.age = 25 | Inconsistent > c.name = "delirious" | phase > > begin > c.save // Make data consistent again > rescue DuplicateEntryError > puts "There's already an entry by that name in the addressbook." > end Yup. I'd then think hard about whether I wanted a class AddressBook, or whether I just have a bunch of contacts. This is not an obvious choice, and to some extent it depends on where you want to take the application in the future. However, something to consider might be: contact = Contact.with_name('Simon V') contact.age = 25 contact.save rescue ... (Of course you'd never really store 'age'... ) Cheers Dave