0

I need to create class method and I'd like to model the method's behavior. Which diagram should be used to do this?

Thank you,

T

1
  • What do you mean by method behavior? Code logic/loops and so on? The best for that is code itself. UML is not meant to model program logic itself. Commented Feb 19, 2015 at 15:01

4 Answers 4

1

You can use a sequence diagram to model the method's input and output, plus any calls that are sent to helper methods of the same or other classes.

This level of detail is normally only worth the effort for more complex methods like e. g. parser logic.

Sign up to request clarification or add additional context in comments.

Comments

0

Intercation diagrams are more suitable to modelize method intercations with others objects and methods. In my opinion, the sequence diagram may meet you need.

Comments

0

I guess that the activity diagram would be the most pertinent.

Sequence diagram is dedicated to model set of method call, you can not model a simple thing as a = b+c for exemple

State diagram focuses on the state of your object. For me it is out of your scope.

Activity diagram allows you to model method call and treatment on variable as read a value...

Of course you can combine them for example you can use sequence and activity.

1 Comment

Okay thanks. I read about the activity diagram and it seemed to be for higher level activities, and a method is pretty low level.
0

You got the terms mixed up.

Your class doesn't own a method, it owns an operation. The behavioral implementation of said operation is called the method.

The method is of the abstract type Behavior which can be either one of the concrete subclasses: Interaction, OpaqueBehavior, Activity or StateMachine Operation behavior Each of these Behaviors have a typical representation for their implementation being respectively Sequence Diagram, text or code, Activity Diagram, State Diagram.

In general I often use sequence diagrams, but that depends on your personal preference.

More details about all of that on my website: UML Best Practice: One Operation => One Sequence Diagram

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.