Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I want to draw a UML diagram of my program. Class Barney has a method Yabadaba(Doo d) which takes a parameter of type Doo.

How do I represent that class Doo is used in class Barney in my UML diagram?

share|improve this question
2  
What type of UML-diagram are you creating? Sequence, class, state, activity, ...? –  Kenneth Jul 16 '13 at 20:28
    
@Kenneth class. –  Imray Jul 22 '13 at 21:39

2 Answers 2

At the very least, you want a dependency relationship from class Doo to class Barney:

Dependency

If class Barney maintains an instance of Doo at some point in its life, then the relationship is stronger and becomes an association relationship:

Association

The association relationship can be made even strong by adding a direction.

You can also consider multiplicity, which is the number of elements. This is most useful for if the element is optional or for composition/aggregation relationships. You may also decide that it may not be appropriate to include the Doo class in your model, in which case you can simply indicate the method exists in Barney.

share|improve this answer
    
Yes your assumption is correct! Thanks –  Imray Jul 22 '13 at 21:36

Smells like a homework. Oh well.

I want to draw a UML diagram of my program.

What type of UML diagram? Class, sequence, collaboration? You need to learn to be precise and clear when asking questions.

With that said, I am going to assume you meant to ask for a class diagram (and my answer will be based off that assumption.)

Class Barney has a method Yabadaba(Doo d) which takes a parameter of type Doo.

How do I represent that class Doo is used in class Barney in my UML diagram?

You represent it by having a class artifact for Barney, in a class diagram, and with a method that takes the type (Doo) in question enter image description here

If, the class Barney has a member field of type Doo, in addition to a method that takes an instance of Doo, then, you will have Barney with a Doo field on it.enter image description here

Either that, or as an aggregation/association of some type. This example would show a composition of Barney with Doo. enter image description here

What association/method you use to represent this, that depends on what you want to do. And for that, well, the solution is to read the manual. Hope it helps.

=== edit ===

btw, these images were created with the yuml.me online drawing tool.

share|improve this answer
    
It's not homework at all, but Thanks!! –  Imray Jul 22 '13 at 21:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.