I hacked together some psuedocode based on the certificate example.
(The same logic would apply to students and del.icio.us tags.)
--- Example A ---
[TrainingService]
removeCertificate(id) {
workers = workerDAO.getWorkers()
for each worker in workers {
worker.removeCertificate(id)
}
workerDAO.store(workers);
certificateDAO.delete(id);
}
------------------------------
I might make a small compromise for performance.
--- Example B ---
[TrainingService]
removeCertificate(id) {
workers = workerDAO.getWorkersWithCertificate(id)
for each worker in workers {
worker.removeCertificate(id);
}
workerDAO.store(workers);
certificateDAO.delete(id);
}
------------------------------
Or a big compromise.
--- Example C ---
[TrainingService]
removeCertificate(id) {
workers = workerDAO.removeCertificateFromWorkers(id);
certificateDAO.delete(id);
}
------------------------------
But I wouldn't do this.
--- Example D ---
[TrainingService]
removeCertificate(id) {
certificateDAO.delete(id);
}
[CertificateDAO]
delete(id) {
workerDAO.removeCertificateFromWorkers(id);
...
}
------------------------------
The thing I don't like about example D is that I can't tell from
looking at TrainingService.removeCertificate() that a certificate is
removed from all of the workers before the certificate itself is
deleted.
Also, while workers depend on certificates (they're "certifiable")
certificates probably don't depend on workers. CertificateDAO probably
shouldn't know about workers or WorkerDAO.
Patrick
--
Patrick McElhaney
704.560.9117
http://pmcelhaney.blogspot.com
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]