View Poll Results: Which option?
- 2. You may not vote on this poll
Use multiple associations with constraint text
Use multiple qualified associations
Use a single class with an interface
There is a better way... look for my reply.
Best way to associate a class with others that all can't be valid simultaneously
What are some recommended ways to model the following in a class diagram?
There is a class of Machine, and the Machine may be assigned to a work group (Class Work Group), or assigned to a free pool, or a maintenance pool (if machine needs repair).
A machine can only be assigned to one of the following: a particular work group, the free pool or the maintenance pool.
Class Machine has three associations (multiplicity of 1) that point to the three different classes (Work Group, Free Pool, Maintenance Pool) with a multiplicity of 0..1
A constraint text box is used to point to each association to say that for each instance of machine, only one association can be non-zero at any given time.
this seems to work but is messy
Create a qualified association from each pool/workgroup Class that points to the Machine Class with a multiplicity of 0..*. The qualifer for each one might be Assign=Free, Assign=Maintenance, or Assign=<workgroup-id>.
My understanding is that a qualifed association should result in mapping to zero to one instance (i.e. multiplicity is 0..1). In this case, any pool or work group needs to be able to map to 0 to many instances (of the Class Machine).
create a class called inventory that associates to all the machines (0..*) and has an Locater interface class associated with it that has operations such as findbyID(), findbyAssignmentType().
Which of these options are reasonable? Is there a better option?
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL