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
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
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.
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.
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
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