UML Representation of Type Passed as a Parameter

methodsparametersuml

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?

Best Answer

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.

Related Topic