Modeling question: lists that depend on each other but can be specialized items?
Trust me, I thought about this issue a lot before asking here and I think I have a solution, but I would like to see what you guys can come up with before deciding on my own :)
SCENARIO:
We got 3 objects in the domain: treatment, beauty salon and worker. In beautyshop it is possible to hire 0 for many employees. Beautysalon now has a list of possible treatments it can do for its clients. Each treatment has a description, duration and price. Each employee has a similar list, but each employee can specialize in each treatment (different price or duration), add new treatments, or "remove" procedures from the beautyshop.
.. This seems like a pretty common problem to me, so I was hoping someone would come up with something clever :)
So far, I've been thinking about letting each treatment have a unique ID, and then letting the employee list the treatments themselves, which will have the same ID as the one in the store. These procedures for employees will override those with the same ID.
Thanks in advance
a source to share
Are we talking about an objective view of a problem or a database view of a problem? If this is an objective view, then specialized treatment should simply be a subclass of general treatment.
With a relational database view, things get a little more complicated:
beautyshop ---= employee
beautyshop ---= treatment_type
treatment_type ---= treatment
employee =--= treatment
( ---=
- one for many, =--=
- many for many).
But how do we get the list of procedures available in the beautyshop? We don't. Instead, we get a list of procedures available from all beautyshop employees. However, if the beautyshop has 0 employees, it does not service treatment.
You can use null fields in the table treatment
to indicate that a particular employee is doing this processing with default properties. If the value of the treatment_type parameter is changed for a particular beautyshop, then all treatments are updated.
a source to share
I would suggest adding some kind of inheritance / specialization mechanism in Treatments
by adding a reference parentTreatment
to the class Treatment
. You will have a set of default ones Treatments
, and everyone Employee
can choose and customize them.
BeautySalon
will not explicitly store any Treatments
, transient and volatile method getAvailableTreatments()
will iterate over the related Employees
and aggregate the parent Treatments
Treatments
suggested by each Employee
.
a source to share