OO question
- From: fejkadress@xxxxxxxxxxxx
- Date: 31 Dec 2006 19:47:12 -0800
I want to make an addressbook and I'm new to OO programming, so I
wonder if this sounds reasonable.
I think of making a class Address which contains all data about one
person, that class can have UserDict as baseclass so I can access data
like object['name'], etc..
Then maybe I can have a class AddressBook which has a list that
contains all those Address objects.
Does that sound reasonable?
And then the real reason that I posted here is:
If I want to save all addresses to disk, I can have a method, say,
save() of AddressBook. But then what? What is a good object oriented
approach? Should each Address object take care of saving itself to the
file, with a method like writetofile(filename), or should the class
AddressBook take care of the saving and ask each object for its data?
Thanks!
.
- Follow-Ups:
- Re: OO question
- From: robert
- Re: OO question
- From: John Machin
- Re: OO question
- From: Paddy
- Re: OO question
- From: Steven D'Aprano
- Re: OO question
- Prev by Date: Re: Why does Python never add itself to the Windows path?
- Next by Date: Re: I want to see all the variables
- Previous by thread: Re: Why does Python never add itself to the Windows path?
- Next by thread: Re: OO question
- Index(es):
Relevant Pages
|