Re: class diagram question

From: Uncle Bob (Robert C. Martin) (u.n.c.l.e.b.o.b_at_objectmentor.com)
Date: 12/20/03


Date: Sat, 20 Dec 2003 10:29:48 -0600


"Passero" <yanongena@pandora.be> might (or might not) have written
this on (or about) Fri, 19 Dec 2003 12:04:51 GMT, :

>When i have a class that uses a static method of another class, do i have to
>draw a link between those classes in my class diagram or do I only need to
>draw the link when i'm using an instance of a class in my class?

You don't *have* to draw any link you don't want to draw. UML
diagrams are about communication, not declaration. Indeed, it is
often more important to leave things *out* of a UML diagram, than to
include them.

If, however, you want to communicate to your readers that methods of
class X invoke static methods of class Y, then you should draw the
association. You can stereotype it with <<static>> if you like.

>Is it the
>same when i parse an object of another class as a parameter but still don't
>use it as an atribute?

Almost. I usually use <<parameter>> stereotypes on associations to
denote that. Martin Fowler prefers dependency arrows.
>
>In java it would be something like this:
>
>public void myFunction()
>{
> Myclass.doMethod(aClassOfMine)
>}
>
>aClassOfMine is an instance of a self-written class and MyClass is another
>class.

>In MyClass i only use aClassOfMine in the method doMethod so do i have to
>draw a link between the class that calls doMehod and MyClass and do i also
>have to draw a link between MyClass and ClassOfMine ?

Again, you don't *have* to. If you think it helps your readers, then
go ahead.

Robert C. Martin | "Uncle Bob"
Object Mentor Inc. | unclebob @ objectmentor . com
501 N. Riverside Dr.| Tel: (800) 338-6716
Suite 206 | Fax: (847) 775-8174 | www.objectmentor.com
                    | | www.XProgramming.com
Gurnee, IL, | Training and Mentoring | www.junit.org
60031 | OO, XP, Agile, C++, Java, C# | http://fitnesse.org



Relevant Pages

  • Re: class diagram question
    ... > draw a link between those classes in my class diagram or do I only need to ... > aClassOfMine is an instance of a self-written class and MyClass is another ... Interaction Diagram for any behavioral collaboration between different ... swimlanes with a specific object identifier. ...
    (comp.object)
  • Re: Hey, Jobst, on p39 of The Bicycle Wheel the graph appears to show the ?impossibility of...
    ... On a drawing with the scale of Jobst's figure, ... small displacements either side of zero. ... What's confusing about the diagram is that it's showing a different ... and because the left lateral force line is drawn ...
    (rec.bicycles.tech)
  • Re: DCC occupancy detections false positives
    ... Could you perhaps draw up a version in Paint that could be posted somewhere? ... The four ordinary diodes on the left are most easily found together in ... short out the rectifier's `+' and `-' terminals ... the diagram at that link looks better. ...
    (rec.models.railroad)
  • Re: Hey, Jobst, on p39 of The Bicycle Wheel the graph appears to show the ?impossibility of...
    ... that is actually a graph of. ... Actually I did say I would draw the diagram differently in the sense ... After numerous posts apparently criticising the drawing, ...
    (rec.bicycles.tech)
  • Re: Rigid rod problem
    ... >>that sense it's not a surprising result at all. ... >>diagram and, say, pick some point on the leftmost ... >>hyperbola and draw the tangent there. ...
    (sci.physics.relativity)