On Thu, 01 May 2003 at 16:28 GMT, MikkelFJ wrote:
> In a non-distributed OO design I would not be overly concerned with the
> potential dangers of some external piece of source changing the Contact
> object in the original design proposal. Things can easily become
> over-engineered. If access rights become a concern later, a private flag can
> control access mode and update methods can check this flag. If there is no
> write access an exception is thrown. Doing the check against access rights
> can also be extended to generate notifications against listeners (such as
> the AddressBook and potentially all interested clients).

I agree. Since this is to be a lightweight non-distributed *Personal*
Addressbook I would certainly go this way. 

There is one thing that still puzzles me though: whether to allow for a
'forbidden/incomplete' object to exist at any point or not. Suppose I
decide that a Contact instance without a 'Name' is utterly pointless and
should _not_ be entered in the addressbook at all. It is easy to have
contacts refuse inconsistent or forbidden data (like an empty name or a
wrong birth-date format) but how do I make sure all contacts that are
created are (or become) consistent ?

Given the way I am currently going with this design I see 2 ways to
implement this:

[1] Make it impossible to create an 'incomplete' contact by requiring
    the name at construction (and making sure it cannot be set to nil or ""
    afterward).

[2] Allow clients to create an 'incomplete' (nameless) draft version of
    the contact and have them call some #validate function that checks
    the completeness of the contact and creates the definitive version.

I would like to go for [1] since it is very simple but in many cases it
just shifts the complexity to the client since the client now has to
buffer data in a structure that probably looks a lot like Contact until
it has enough to create a valid contact. 
So I guess I should use [2] but I don't know how to do that ... do I
create two classes of objects: IncompleteContact and Contact. Generate
the second from the first through validation ?


Still a long way to go ...

- Simon



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