I have a EMP table in database. My application has Emp.java mapping to this table. There is EmpSingleton.java which is a singleton class in the system, which has a vector which will load all the Emp records. So when a employee information is required first we get a reference to the singleton and then get the details of the particular record In the constructor of the EmpSingleton, the vector is created but the records are not loaded. The client invokes a seperate function to load the records of Emp. Now in UML if I show the objects EmpSingleton and Emp what will be the kind of relation between these two. Will it be assocation/aggregation/composition?
[ June 21, 2006: Message edited by: l al ] [ June 21, 2006: Message edited by: l al ]
I wouldn't call it composition becasue the singleton doesn't seem to be made up of Employees. It holds a collection of them but that doesn't quite feel the same.
By the way: This may be fine as a learning exercise, but I'd consider alternatives to this design idea for a system of any size or complexity. What if you get too many Employees to fit into memory at the same time? How long will it take to load them? How will you handle updates back to the database or file ... could some class change an Employee object and never tell the singleton? What if two or more copies of this program need to update the employee database at the same time? How do you create new Employees?
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
subject: what will be the realtion association/aggregation ?