lutaml / lutaml-uml

UML module for LutaML
2 stars 2 forks source link

UML syntax: Operations #21

Open ronaldtse opened 4 years ago

ronaldtse commented 4 years ago

Operations

Notation and Semantics

Operation Property

Pre-Post-Body conditions

Difference between body condition and postcondition

Examples

w00lf commented 4 years ago

Operations

  • Def.- An operation is a behavioral feature of a classifier, which specifies name, type, parameters and contraints for the call of the behavior.
  • In addition to the features and operation inherits from BehavioralFeature, the operation can:

    • Have preconditions and postconditions and a body condition.
    • Specify whether it will change the state of the pertaining instance (see isQuery).
    • Have a type.

Notation and Semantics

  • Although the syntax of operations is described somewhat imprecisely in the UML specification, the notation should look like this: [visibility]name(parameter list) [:type][{property string}]

Operation Property

  • {query} can be used to specify a property value for the operation.
  • This characterizes an operation that has no side effects, that is, an operation that does not change the state of the object and other objects such as get() operations

Pre-Post-Body conditions

  • The precondition must always be true before the operation is executed.
  • The postconditions have to be true after the exection.
  • The body condition has to be true during the execution.
  • If an exception occurs during operation execution, the postconditions must not be true.

Difference between body condition and postcondition

  • The difference between body condition and postcondition is that the invariant (of the body condition) can be overwritten (redefined) by inheritance.
  • A postcondition merely lets you add postconditions. The latter is also true for a precondition.

Examples

  • getPosition(return x:int, return y:int)
  • Enlarge(byFactor:Real):GeomFigure
  • +addPhone(phone:String)
  • #release():contractStatus

@ronaldtse duplicate of #20 ?

ronaldtse commented 4 years ago

Operations

  • Def.- An operation is a behavioral feature of a classifier, which specifies name, type, parameters and contraints for the call of the behavior.
  • In addition to the features and operation inherits from BehavioralFeature, the operation can:

    • Have preconditions and postconditions and a body condition.
    • Specify whether it will change the state of the pertaining instance (see isQuery).
    • Have a type.

This is the difference. An operation is a feature of the classifier (e.g. Class). It extends from feature by:

  1. it allows conditions pre/post/during
  2. it allows specifying whether it is a Query or not (Query means doesn't change data)
  3. Have a type.