Here is hopefully a new perspective to your question, and a solution with a rationale
...
Inference 1: Since you chose to model Company explictly as an object, there are
multiple companies in the system.
Inference 2: Since you mention the word "history", it is also true that a person is
employed by multiple companies at
different points in time
Inference 3: There is no strong evidence to suggest that a person can be employed by
more than one company at any given
instant of time. However, since you have explictly mentioned "bidirectional
association" and also taken to explicitly
mark multiplicity as "many" at the Person end, I can reasonably conclude that a person
does not indeed have multiple
employments at a given instant is time.
Your question can be restated as
Is it worth creating an abstraction such as EmploymentHistory?
The reason that causes the question is because
a) you have some specific behavior [ like getNumberOfJobJumps(int year) ]
and also attributes [ salary, joinDate, etc ] that are
related to the history itself, that needs to be "maintained"
b) you have the option of not creating a new abstraction, because it can be reasonably
argued that the same can be
achieved by existing abstractions (Person, Company)
The answer IMHO is simple, create a new abstraction called "Employment".
EmploymentHistory is just a collection of
employment objects for a given person (could also be for a company, if you are willing
to look at it differently).
Anything interested in maintaining it, can do so ! You can keep the history in Person,
Company or in neither - depends
on how you will access this object, for what and the frequency of access from all
directions !
The reason you dont want to have these attributes/behavior as part of Person is
because they are truly not the
characteristics of either ends of the relationship (or you can also say that they can
equally be assigned as
characteristics to either ends of the relationship !). The very fact that you need to
also create Employment as an
abstraction is also because the two related objects here are named "Company" and
"Person". Employment results only when
the Company plays the role of an Employer and the Person plays the role of an Employee.
In my experience I always find people debating about modeling the triad of
Person-Company-Employment. The same doubt
somehow does not seem to crop for the triad, "Buyer-Seller-PurchaseOrder". Is it
because PurchaseOrder is (perceived to
be) more tangible than Employment?
Regards,
Ramesh Srinivasaraghavan
Architect, Aztec Software
http://www.aztecsoft.com
Disclaimer: My opinions dont necessarily agree or disagree with that of my employer
and other organizations I am
affiliated with
"Biniam Tesfu (PAC)" wrote:
> Hi all,
>
> I am not shoore how to solve the following problem!
>
> I have two classes: "Company" and "Person". And there is a bi-directional
>association between them. It means you can
> navigate in both directions. The Company is the employer, and the Person is an
>employee.
>
> The multiplicity is: one(1) company can employ many(1..*) Persons
>
> Where can I keep the employement history?
> In class "Company" or in class "Person" or in an "association class"?
>
> regards
> Bin/
> ************************************************************************
> * Rose Forum is a public venue for ideas and discussions.
> * For technical support, visit http://www.rational.com/support
> *
> * Post or Reply to: [EMAIL PROTECTED]
> * Subscription Requests: [EMAIL PROTECTED]
> * Archive of messages:
> * http://www.rational.com/support/usergroups/rose/rose_forum.jsp
> * Other Requests: [EMAIL PROTECTED]
> *
> * To unsubscribe from the list, please send email
> * To: [EMAIL PROTECTED]
> * Subject: <BLANK>
> * Body: unsubscribe rose_forum
> *************************************************************************
************************************************************************
* Rose Forum is a public venue for ideas and discussions.
* For technical support, visit http://www.rational.com/support
*
* Post or Reply to: [EMAIL PROTECTED]
* Subscription Requests: [EMAIL PROTECTED]
* Archive of messages:
* http://www.rational.com/support/usergroups/rose/rose_forum.jsp
* Other Requests: [EMAIL PROTECTED]
*
* To unsubscribe from the list, please send email
* To: [EMAIL PROTECTED]
* Subject: <BLANK>
* Body: unsubscribe rose_forum
*************************************************************************