Object Oriented Software Engineering   View all facts   Glossary   Help
subject > programming language construct > statement > OCL statement > OCL statement in a class diagram
UpOCL statement

OCL statement in a class diagram
subjectfact 
OCL statement in a class diagramcan specify what the values of attributes and associations must be2001-08-30 14:56:50.0
can state the preconditions and postconditions of operations2001-08-30 14:56:50.0
is a subtopic of 5.6 - More Advanced Features of Class Diagrams2001-08-30 14:56:50.0
is a kind of OCL statement2001-08-30 14:56:50.0
OCL statementcan be used for automatic code generation2001-08-30 14:56:50.0
can consist of
  • References to role names, association names, attributes and the results of operations.
  • The logical values true and false
  • Logical operators such as and, or, =, >, < or <> (not equals)
  • String values such as: 'a string'
  • Integers and real numbers (the latter having a decimal point)
  • Arithmetic operations *, /, +, -
2001-08-30 14:56:50.0
can navigate from class to class using a dot to separate components. For example, in LinearShape, to refer to the length of the edges you can refer to edge.length.2001-08-30 14:56:50.0
can refer to all the values in a collection using the forall operator2001-08-30 14:56:50.0
can refer to special OCL properties of a collection itself using the -> operator2001-08-30 14:56:50.0
can use the {ordered} constraint to indicate that an OCL collection is a sequence, which allows you refer to special properties such as first and last2001-08-30 14:56:50.0
can use the implies operator which is true if either the left hand side is false or if both sizes are true2001-08-30 14:56:50.0
does not have to be written on a UML diagram but can be written separately with a context specified2001-08-30 14:56:50.0
has example {startPoint <> endPoint} constrains the two ends of a LineSegment to be different2001-08-30 14:56:50.0
is not compiled2001-08-30 14:56:50.0
is not executed2001-08-30 14:56:50.0
statementshould be not more than one line long if possible2001-08-30 14:57:47.0

UpOCL statement