Re: UML inner/nested class associations
- From: "H. S. Lahman" <h.lahman@xxxxxxxxxxx>
- Date: Thu, 20 Apr 2006 15:44:45 GMT
Responding to VisionSet...
Caveat. My response below is controversial because I do not like the direction that OMG is taking UML. There is a camp within OMG that is trying to make UML a tactical design tool so that one can express things like ActiveX implementations. I belong to the camp that believes UML is an OOA/D tool that should live at a higher level of abstraction (e.g., ActiveX is only one mechanism for implementing the OOA/D design logic so that should be left as a prerogative of OOP).
If you have an inner class that creates stateless objects then you can do
this in a number of ways.
1/ A nested class, Objects of the class can be composed attributes of outer
object.
2/ A nested class, Objects of the class are just instantiated in method
scope.
3/ An inner class declared in a method. Objects are just instantiated in
method scope.
In UML only 1/ can be shown as a composisition (?) association although the
designed effect is the same.
How can I legally show relationships in the other cases? At the moment I'm
using notes & note anchors. I was using the dotted instantiates/dependency
relationship, but I now realise that is misuse.
Can you show relationships for method local objects at all?
I expect the answer might be, 'this is what sequence diagrams are for'.
My short answer is: You don't need to.
Your three examples are all closely tied to 3GL context. At the OOA/D level in UML one doesn't really care which solution is used in the 3GL implementation. The fundamental logic of the solution will be the same regardless of which implementation is chosen. Choosing a specific implementation will depend upon things like language syntax, referential integrity context, programmer convenience, dependency management, and a bunch of other pure OOP issues.
So my answer is: solve the problem abstractly at the OOA/D level using natural problem space abstractions and don't worry about how it will be implemented at the 3GL level. So...
Also when naming associations, does the naming direction go in the direction
of a one way association by default? I believe you can have it in either
direction, but there is no visual way to indicate direction? How can you
read direction in 2 way associations? Also my names seem a bit over-long eg
'connects to database via'.
example here:
http://img126.imageshack.us/img126/5078/dao4bv.gif
Nested class is RowHandler, a locally used object is DAOException.
You have identified a suite of classes necessary to communicate with an RDB. Those classes will have natural collaborations as peers to convert the application view (presumably a game of some sort) into an RDB view. You can express those collaborations without worrying about how the objects will be implemented. The fundamental collaborations to convert views will be the same (and probably quite reusable across applications!)
The only reason you might want to use a composition association here is to specify a referential integrity constraint where one object's life cycle is tied to another's. For example, you might not want a DAOException object to exist beyond the life of a specific UserDao or GameDAO. (I have no idea whether that is true for your problem; the point is the problem context will dictate the composition constraint.) If there is such a life cycle constraint, then it will have to be honored at OOP time by implementing one of the three strategies above. Then (1) will probably require the least effort, but any of them could be made to enforce it.
*************
There is nothing wrong with me that could
not be cured by a capful of Drano.
H. S. Lahman
hsl@xxxxxxxxxxxxxxxxx
Pathfinder Solutions -- Put MDA to Work
http://www.pathfindermda.com
blog: http://pathfinderpeople.blogs.com/hslahman
(888)OOA-PATH
.
- Follow-Ups:
- Re: UML inner/nested class associations
- From: VisionSet
- Re: UML inner/nested class associations
- References:
- UML inner/nested class associations
- From: VisionSet
- UML inner/nested class associations
- Prev by Date: Re: Question on Effective Java Item 27
- Next by Date: Re: Question on Effective Java Item 27
- Previous by thread: UML inner/nested class associations
- Next by thread: Re: UML inner/nested class associations
- Index(es):
Relevant Pages
|