On Thu, 01 May 2003 at 13:12 GMT, Dave Thomas wrote:
> 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 ...

I think you are showing me the contact's persistence need not
necessarily be the Addressbook responsibility, a contact could persist
itself if it mixed in a StorableObject module ?
So instead of telling my addressbook to save all contacts at the end of
the application, every contact would be saved to file as soon as #save
was called on it ...

Wouldn't I still need an object that keeps track of all the instantiated
contacts. How else am I going to generate a sorted list of contact names
for the UI ? Who is going to answer sophisticated search queries (give
me all contacts born between 1977 and 1987.) I could achieve this using
the ObjectsSpace in my client but is that really good design ?
Especially since many clients are probably going to want that query
functionality ...


> (Of course you'd never really store 'age'... )

Why not , all I have to do is remember to run 
Addressbook.each {|c| c.age += 1} every year ;^>




-- 
There are 10 types of people in the world... 
those who understand binary and those who don't.