Behavior versus working in UML

As I know,

the operation is in the second compartment of the class in the class diagram.

The following is the Behavior definition from the UML specification (August 2011, p. 445)

13.3.2 Behavior (from BasicBehaviors)

Behavior is a specification of how its context classifier changes over time. This specification can be either a definition of possible behavior or the occurrence of behavior, or a selective illustration of an interesting subset of possible executions. the latter form is commonly used to capture examples, such as tracing a specific execution. Classifier behavior is always a definition of behavior, not an illustration. It describes the sequence of state changes an instance of the classifier may undergo the course of its life. Its exact semantics depends on the type of classifier. For example, the behavior of a collaboration classifier is the occurrence of the behavior of all parts, while the classifier of class behavior is simply the behavior of instances of a class separated from the behavior of any of its parts. When behavior is associated as a method of a behavioral function, it determines the implementation of that function (that is, a computation that generates effects of the behavioral function).

1) Could you explain what this behavior is in the above definition?

2) What are the differences between behavior and work in a unified modeling language (UML)?

+4
source share
3 answers

An operation is only an element of the specification — imagine that it is like a method signature in OO programming languages. It has a name and a list of options.

Behavior - in particular, is what the operation (or another behavioral function, such as a reception) does when invoked - imagine that this is the body of the method.

UML actually calls a "method" behavior that determines what the operation does. In addition, from the behavior (whether it is an operation or a state machine), the operation is visible as a “specification”.

Note that there may be several methods in UML operations. What this means and what behavior should be performed when invoking the operation depends on the tool in question.

Finally, behavior can be state machines or actions — actions are easy to understand because they are equivalent to procedural code. State machines are a completely different beast, and I admit that I do not understand how a state machine can be used as behavior for an operation.

+2
source

To be precise:

In a UML class diagram, a class usually has 3 common compartments: there may be more, since custom compartments can be added to the class drawer form.

In practice, the order of the compartments:

  • Clas name
  • The properties
  • Operations

Thus, the third inclusion is used for “operations”.

Behavior:? What do you mean by Behavior?

In terms of OO terms, there are properties (attributes) [car has color] and behavior (operations) [car acceleration, stop, etc.].

In UML terminology, the implementation of an operation is called a method .

And we use interaction diagrams (sequence or teamwork) to study dynamic behavior systems that we will build or explore.

+1
source

Specializations: OpaqueBehavior, Activity, StateMachine, Interaction For example, OpaqueBehavior for "i = i + 1;"

BehavioralFeature specification: Operation, reception For example, operation "void foo ()"

Combination . Behavior can be invoked directly, through a BehavioralFeature, which it implements as a method or as a classifierBehavior BehavioredClassifier.

For instance,

 void foo() { i = i + 1; } 

UML gives the developer flexibility that "assigns" an operation with different "behavior" to the call. For example, if there is another behavior of "MyStateMachine", you can simply assign the operation "foo" to call it.

 void foo() { (new MyStateMachine(this)).run(); //Create an instance of it, pass the current classifier as context of the behavior } 
+1
source

Source: https://habr.com/ru/post/1485265/


All Articles