Re: Subset of relationship
Re: Subset of relationship
- Subject: Re: Subset of relationship
- From: email@hidden
- Date: Wed, 10 Aug 2005 10:35:34 -0500
> If I had three specialization brands under Message,
the problem
> would be
> even harder.
>
> Besides, if I had a hierarchy like:
> Person -------------------------
> |
|
> Native ----- Foreigner
Customer ------ Employee
>
> each specialization of each brand would possibly have its own
> properties
> and relationships. In that case, creating a person as a Customer would
> just make his or her unable to be classified as Citizen or Foreigner.
Emerson,
Now you've come upon why you would not want to model state using inheritance.
My two cents worth:
Native vs. Foreigner is a difference
in origin, which is an attribute (of Person)
Customer vs. Employee is a difference
in roles (of Persons), which can be state, but probably should be modeled
as a Customer (role) relationship of a Person to the vendor, like Ken's
component suggestion.
Draft vs. Sent is a difference in state
of a message.
Changing an object's state should not
mean it always has to change it's class.
Going back to your original problem,
a person has messages, some of which have been sent and some are draft,
and you want a User to have different attributes for "sent" and
"draft".
I don't have EOModeler in front of me
right now, but I thought there was a way to specify the qualifier that
decides which records map to a relationship.
However (!), I'll guess a message can
change state from draft to sent (but not the other way), and unless you
saveChanges immediately after sending a message, then the relationships
are not going to give you the latest state - you would effectively be using
the database query to decide _which relationship_ a message entity belongs
to, and the database knows nothing of any changes in memory but not yet
saved. (Am I right?)
I think _I_ would just write a method
to return the EOArray of Message entities which are draft, and another
method to return the Messages sent, each of which used the Messages relationship
which encompasses all messages of any state. (These methods might
/might not use a EOFetchSpecification if you just wanted the initial drafts
or sent messages but not both.) This may not be "the EO way",
but it's straightforward.
Hope this makes sense and helps,
Chris
email@hidden _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden