When I look at the functionality provided by the Assignment Module to assign a Resource to a Project, the purpose seems very similar to the Assign method in the ProjectResources collection.
I am sure I'm missing something, and I know how each one works (basically), but I don't know why ProjectResources wouldn't just use the Assignment module via the ProjectResource to add one to the list.
What am I missing about this?
Was this just a variation for the purposes of demonstrating in the sample?
I feel like I'm missing something.
Thanks in advance.
It is a somewhat contrived example. But at the same time, the overall idea is to illustrate how to implement a many:many relationship between objects.
The classic example is doctor:patient. A doctor has many patients, and a patient may have many doctors.
In a database this is a M:M relationship, usually implemented with three tables: Doctors, Patients and DoctorPatient.
But in an object model that simplistic data-centric view is insufficient. Objects are designed around behavior, and the data model doesn't really reflect behavior, just static relationships.
In an object model, a doctor has a list of relationships to patients. A doctor doesn't own patients - slavery is illegal in most of the world. And a patient doesn't own a doctor for the same reason.
So a doctor object would have a collection of PatientRelationship objects or PatientVisit objects or something that reflects the user scenario the objects are serving.
Similarly, a patient object would have a collection of DoctorVisit objects or something like that.
At the database level they do both add a resource to a project,
yes.
But at an object level the relationships are different, and the
data surrounding those relationships could be different. In most cases the data
surrounding the relationships would probably be different, because the usage
scenarios would be different.
If they really are the same, and the available data is the same,
then the data access code could be consolidated.
Rocky
As usual, you have cleared things up.
I will say that I am still trying to shake the relational overtones to my thinking. I did Smalltalk in the late 80's and we were much more concerned with inheritance of attributes and behavior than with reusable behavior. Of course, "Hello, wolrd!" was 5mb when computers were lucky to 32mb to work with.
Copyright (c) Marimer LLC