Appendix... B. The Object Constraint



Similar documents
Home Assignment 4 OCL

UML TUTORIALS THE USE CASE MODEL

Execution of A Requirement Model in Software Development

Using UML Part Two Behavioral Modeling Diagrams

Model Driven Security: Foundations, Tools, and Practice

Introduction to Python

Formally speaking: How to apply OCL

Object Oriented Programming. Risk Management

Sequence Diagrams. Massimo Felici. Massimo Felici Sequence Diagrams c

Moving from CS 61A Scheme to CS 61B Java

Case studies: Outline. Requirement Engineering. Case Study: Automated Banking System. UML and Case Studies ITNP090 - Object Oriented Software Design

Communication Diagrams

Menouer Boubekeur, Gregory Provan

Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science. Unit of Study / Textbook Correlation

A Framework for the Semantics of Behavioral Contracts

UML basics: An introduction to the Unified Modeling Language

Java (12 Weeks) Introduction to Java Programming Language

A Meeting Room Scheduling Problem

Java Application Developer Certificate Program Competencies

UML-based Test Generation and Execution

Introduction. UML = Unified Modeling Language It is a standardized visual modeling language.

The «include» and «extend» Relationships in Use Case Models

Software Component Specification Using Design by Contract

Computer Programming I

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Design by Contract beyond class modelling

On translating UML models into graph transformation systems $

Eventia Log Parsing Editor 1.0 Administration Guide

Glossary of Object Oriented Terms

Introduction to Java Applications Pearson Education, Inc. All rights reserved.

Concepts and terminology in the Simula Programming Language

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

6.170 Tutorial 3 - Ruby Basics

Rigorous Software Development CSCI-GA

Algorithm & Flowchart & Pseudo code. Staff Incharge: S.Sasirekha

Rigorous Software Development CSCI-GA

Positional Numbering System

Object Oriented Software Design

CS 106 Introduction to Computer Science I

Formal Engineering for Industrial Software Development

Applying 4+1 View Architecture with UML 2. White Paper

The C Programming Language course syllabus associate level

USERV Auto Insurance Rule Model in Corticon

Fundamentals of Java Programming

Use-Case Analysis. ! What is it? ! From where did it come? ! Now part of UML

Role-based Authorization Constraints Specification Using Object Constraint Language

Object Oriented Software Design

Microsoft Excel Tips & Tricks

IRA 423/08. Designing the SRT control software: Notes to the UML schemes. Andrea Orlati 1 Simona Righini 2

Meta Model Based Integration of Role-Based and Discretionary Access Control Using Path Expressions

How To Write A Test Engine For A Microsoft Microsoft Web Browser (Php) For A Web Browser For A Non-Procedural Reason)

Checking Access to Protected Members in the Java Virtual Machine

Computers. An Introduction to Programming with Python. Programming Languages. Programs and Programming. CCHSG Visit June Dr.-Ing.

Semantic Analysis: Types and Type Checking

Part 1 Foundations of object orientation

Programming and Software Development CTAG Alignments

Effectively Using JML

3 Data Properties and Validation Rules

Java Interview Questions and Answers

Exercise 4 Learning Python language fundamentals

Using UML Part One Structural Modeling Diagrams

Programming by Contract. Programming by Contract: Motivation. Programming by Contract: Preconditions and Postconditions

5 Process Modeling using UML

Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff

Towards a Common Metamodel for the Development of Web Applications

Etudes de cas en OCL avec l outil USE 2

Incorporating Aspects into the UML

Informatica e Sistemi in Tempo Reale

Appendix: Tutorial Introduction to MATLAB

Statements and Control Flow

UML TUTORIALS THE COMPONENT MODEL

The Expressive Power of UML-based Web Engineering 1

How To Program In Scheme (Prolog)

OpenOffice.org 3.2 BASIC Guide

Visual Basic Programming. An Introduction

Aspect Oriented Strategy to model the Examination Management Systems

PL/SQL Overview. Basic Structure and Syntax of PL/SQL

Questions? Assignment. Techniques for Gathering Requirements. Gathering and Analysing Requirements

The previous chapter provided a definition of the semantics of a programming

Understanding class definitions

DTD Tutorial. About the tutorial. Tutorial

ios Dev Crib Sheet In the Shadow of C

Analysis of the Specifics for a Business Rules Engine Based Projects

Creating A Grade Sheet With Microsoft Excel

Assignment # 2: Design Patterns and GUIs

Introduction to ERD modelling using UML Class diagrams with Magicdraw (ver 17)

Software Design. Software Design. Software design is the process that adds implementation details to the requirements.

Scenario-based Requirements Engineering and User-Interface Design

CS 1133, LAB 2: FUNCTIONS AND TESTING

Chapter 5. Selection 5-1

Once the schema has been designed, it can be implemented in the RDBMS.

Chapter 13: Program Development and Programming Languages

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

Solutions of Linear Equations in One Variable

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

[Refer Slide Time: 05:10]

WESTMORELAND COUNTY PUBLIC SCHOOLS Integrated Instructional Pacing Guide and Checklist Computer Math

Unix Shell Scripts. Contents. 1 Introduction. Norman Matloff. July 30, Introduction 1. 2 Invoking Shell Scripts 2

BPMN Business Process Modeling Notation

Software Engineering Techniques

Transcription:

UML 2.0 in a Nutshell Appendix B. The Object Constraint Pub Date: June 2005 Language The Object Constraint Language 2.0 (OCL) is an addition to the UML 2.0 specification that provides you with a way to express constraints and logic on your models. For example, you Table can use of Contents OCL to Index convey that a person's age must always be greater than 0 or that a branch office must always have one secretary for every 10 employees. OCL System isn't developers new to UML have 2.0; used it was modeling first introduced languages in UML for decades 1.4. However, to specify, as of visualize, UML 2.0, it was formalized construct, using and document the Meta-Object systems. Facility The Unified and UML Modeling 2.0. From Language a user's (UML) perspective is one of the those languages. has UML been makes updated it possible and refined for team but the members fundamentals to collaborate remain by the providing same. This a common appendix introduces language that the basic applies concepts to a multitude of OCL. of For different more detailed systems. information, Essentially, consult it enables the OCL you to specification communicate available solutions from in a the consistent, Object Management tool-supported Group's language. web site (http://www.omg.org/).

UML 2.0 in a Nutshell B.1. OCL Basics Pub Date: June 2005 The Object Constraint Language is just that: a language. It obeys a syntax and has keywords. However, unlike Pages: other 234 languages, it can't be used to express program logic or flow control. By design, OCL is a query-only language; it can't modify the model (or executing system) in any way. It can be used to express preconditions, postconditions, invariants (things that must Table always of Contents be TRue), Index guard conditions, and results of method calls. OCL can be used virtually anywhere in UML and is typically associated with a classifier using a note. System When developers an OCL expression have used modeling is evaluated, languages it is considered for decades to be to instantaneous, specify, visualize, meaning the associated construct, classifier and document can't change systems. state The during Unified the Modeling evaluation Language of expression. (UML) is one of those languages. UML makes it possible for team members to collaborate by providing a common language that applies to a multitude of different systems. Essentially, it enables you to communicate solutions in a consistent, tool-supported language. B.1.1. Basic Types OCL has several built-in types that can be used in OCL expressions: Boolean you who Must must be either read, true create, or false. and understand Supports system the logical artifacts operators expressed and, or, using xor, not, UML. implies, Furthermore, and if-then-else. it's been fully revised to cover version 2.0 of the language. Integer Any integer value (e.g., 100, -12345, 5211976, etc.). Supports the operators *, +, -,/, Topics and include: abs( ). Real The Any object-oriented decimal value (e.g., paradigm 2.222003, and its -67.76, relation etc.). to the Supports UML the operators *, +, -,/, and floor( ). String A series of letters, numbers, or symbols interpreted as a string (e.g., "All writing and no Extension play make Mechanisms Dan..."). Supports the operators concat( ), size( ), and substring( ). In addition The Object to the Constraint built-in types, Language any classifier (OCL) used in your UML model is recognized as a type by OCL. Because OCL is a strongly typed language, you can't compare values of one type directly with values of another type. B.1.2. Casting OCL does support casting objects from one type to another as long as they are related through a generalization relationship. To cast from one type to another use the operation

oldtype. oclastype(newtype). For example, to cast a Java List to an ArrayList to call the size( ) operation, use the expression: UML 2.0 in a Nutshell List.oclAsType(ArrayList).size( ) If the actual object Pub Date: isn't an June instance 2005 of the new type, the expression is considered undefined. construct, and document systems. The Unified Modeling Language (UML) is one of those languages. UML makes it possible for team members to collaborate by providing a common language that applies to a multitude of different systems. Essentially, it enables you to communicate solutions in a consistent, tool-supported language.

UML 2.0 in a Nutshell B.2. OCL Syntax The remainder of Pub this Date: chapter June 2005 uses examples from the class diagram shown in Figure B-1. B.2.1. Constraints on Classifiers Each OCL expression must have some sense of context that an expression relates to. Often the System context developers can be determined have used modeling by where languages the expression for decades is written. to specify, For example, visualize, you can link a construct, constraint and to an document element systems. using a note. The Unified You can Modeling refer to Language an instance (UML) of the is context one of those classifier using languages. the keyword UML makes self. it For possible example, for if team you members had a constraint to collaborate on Student by providing that their a GPA common must always language be that higher applies than 2.0, to a you multitude can attach of different an OCL systems. expression Essentially, to Student it enables using a note you to and refer communicate to the GPA solutions as follows: in a consistent, tool-supported language. Today, self.gpa UML has > become 2.0 the standard method for modeling software systems, which means Figure B-1. Example class diagram used in this chapter It's important to realize that this OCL expression is an invariant, meaning the system would be in an invalid state if a student's GPA dropped to less than 2.0. If you want to allow a GPA of less than 2.0 and send out a letter to the student's parents in the event such a low GPA is achieved, If you're new you would to UML, model a tutorial such with behavior realistic using examples a UML diagram has even such been as included an activity to help or you interaction quickly familiarize diagram. yourself with the system. You can follow associations between classifiers using the association end names as though they were attributes of the originating classifier. The following invariant on Course ensures that the instructor is being paid:

self.instructor.salary > 0.00 If an association UML has 2.0 a in multiplicity a Nutshell of 0..1, you can treat the association end as a Set and check to see if the By Dan value Pilone, is Neil set Pitman by using the built-in notempty( ) operation. To call the notempty( ) operation on a set you must use an arrow (->) rather than a dot (.). See "Collections" for Publisher: more information O'Reilly on sets. The following invariant on Course enforces that a course has an instructor: Pub Date: June 2005 self.instructor->notempty( ) If an association role name isn't specified, you can use the classifier name. The following invariant on School checks that each course has a room assignment: construct, self.course->forall(roomassignment and document systems. The Unified <> Modeling 'No room!') Language (UML) is one of those languages. UML makes it possible for team members to collaborate by providing a common language that applies to a multitude of different systems. Essentially, it enables you to Comments communicate can solutions be inserted a into consistent, an expression tool-supported by prefixing language. each comment with two dashes (), like this: even -- though make you sure may this not student write UML could diagrams graduate yourself, you'll still need to interpret diagrams self.gpa written > 2.0 by others. If you you who can't must determine read, create, the context and understand of expression system by artifacts looking expressed at the UML using model, UML. or if you want Furthermore, to be explicit it's been with fully the context, revised to use cover the OCL version keyword 2.0 of context, the language. followed by the classifier name. If you use this notation, you should say what the expression represents. In the following This comprehensive case, we're new showing edition an invariant, not only provides so we use a quick-reference the keyword inv. to Other all UML types 2.0 diagram of expressions types, it also are explains explained key in concepts later sections. in a way that appeals to readers already familiar with context Student Topics inv: include: self.gpa > 2.0 Instead of using the keyword self, you can assign a name to a classifier that you can use in the expression. The object-oriented Write the name paradigm you and want its to relation use, followed to the by UML a colon (:) and then the classifier name. For example, you can name the instance of Student as s: context s : Student inv: s.gpa > 2.0 Finally, you can name an expression by placing a label after the expression type but before the colon The (:). Object The Constraint label is purely Language decorative; (OCL) it serves no OCL function. context s : Student inv minimumgparule: s.gpa > 2.0 B.2.2. Constraints on Operations Beyond basic classifiers, OCL expressions can be associated with operations to capture

preconditions and postconditions. Place the signature of the target operation (classifier, operation name, parameters, etc.) after the context keyword. Instead of the invariant keyword, use either pre or post for preconditions and postconditions, respectively. UML 2.0 in a Nutshell The following expression By Dan Pilone, ensures Neil Pitman that any student who will be registered for a course has paid their tuition: Pub Date: June 2005 context Course::registerStudent(s : Student) : boolean pre: s.tuitionpaid = true Table When of Contents writing postconditions, Index you can use the keyword result to refer to the value returned by an operation. The following expressions verify that a student's tuition was paid before registering for a course and that the operation registerstudent returned true: construct, context and Course::registerStudent(s document systems. The Unified : Student) Modeling Language : boolean (UML) is one of those languages. pre: s.tuitionpaid UML makes possible = true for team members to collaborate by providing a common language post: that result applies = true to a multitude of different systems. Essentially, it enables you to communicate solutions in a consistent, tool-supported language. As Today, you can UML with has invariants, become the you standard can name method preconditions for modeling and software postconditions systems, by placing which means a label after you're the probably pre or post confronting keywords: this rich and expressive language more than ever before. And context Course::registerStudent(s : Student) : boolean pre haspaidtuition: s.tuitionpaid = true post studentwasregistered: result = true Postconditions This comprehensive can use new the edition @pre keyword not only to provides refer to a the quick-reference value of some to element all UML before 2.0 diagram an operation types, it also executes. explains The key following concepts expression in a way ensures that appeals that a to student readers was already registered familiar and with that the UML number or object-oriented of students in programming the course has concepts. increased by 1. This expression uses the self keyword to reference the object that owns the registerstudent operation. context Course::registerStudent(s : Student) : boolean pre: s.tuitionpaid = true post: The role result and value = true of UML AND in self.students projects = self.students@pre + 1 You may An specify integrated the approach results of to a query UML diagrams operation using the keyword body. Because OCL doesn't have syntax for program flow, you are limited to relatively simple expressions. The following Class expression and Object, indicates Use Case, that Sequence, honors students Collaboration, are students Statechart, with GPAs Activity, higher Component, than 3.5. The collection and Deployment syntax used Diagrams in this example is described in the "Collections" section. context Course::getHonorsStudents( ) : Student body: self.students->select(gpa > 3.5) B.2.3. Constraints on Attributes OCL expressions can specify the initial and subsequent values for attributes of classifiers. When using OCL expressions with attributes, you state the context of an expression using the classifier name, two colons (::), the attribute name, another colon (:), and then the type of the attribute. You specify the initial value of an attribute using the keyword init:

context School::tuition : float init: 2500.00 UML 2.0 in a Nutshell You can specify the value of attributes after their initial value using the derive keyword. The following example Publisher: increases O'Reilly the tuition value by 10% every time you query it: Pub Date: June 2005 context: School::tuition : float derive: tution * 10% construct, and document systems. The Unified Modeling Language (UML) is one of those languages. UML makes it possible for team members to collaborate by providing a common language that applies to a multitude of different systems. Essentially, it enables you to communicate solutions in a consistent, tool-supported language.

UML 2.0 in a Nutshell B.3. Advanced OCL Modeling Like any other language, Pub Date: June OCL 2005 has an order of precedence for operators, variable declarations, and logical constructs ISBN: (only 0-596-00795-7 for evaluating your expressions, not for program flow). The following sections describe Pages: constructs 234 that you can use in any OCL expression. B.3.1. Conditionals OCL System supports developers basic boolean have used expression modeling evaluation languages using for decades the if-then-else-endif to specify, visualize, keywords. The conditions construct, are and used document only to systems. determine The which Unified expression Modeling is Language evaluated; (UML) they is can't one be of used thoseto influence languages. the UML underlying makes it system possible or for to affect team program members flow. to collaborate The following by providing invariant a enforces commonthat a student's language year that of applies graduation to a multitude is valid only of different she has systems. paid her Essentially, tuition: it enables you to communicate solutions in a consistent, tool-supported language. context Student inv: Today, if UML tuitionpaid has become = true the standard then method for modeling software systems, which means you're yearofgraduation probably confronting = this 2005rich and expressive language more than ever before. And even else though you may not write UML diagrams yourself, you'll still need to interpret diagrams yearofgraduation written by others. = 0000 endif OCL's Furthermore, logic rules it's are been slightly fully revised different to from cover typical version programming 2.0 of the language. logic rules. The boolean evaluation rules are: 1. True OR-ed with anything is true. 2. False AND-ed with anything is false. 3. False The role IMPLIES and anything value of is UML TRue. in projects The implies The object-oriented keyword evaluate paradigm the first and half its of relation an expression, to the UML and, if that first half is true, the result is taken from the second half. For example, the following expression enforces that if a student's GPA is An less integrated than 1.0, approach their year to of UML graduation diagrams is set to 0. If the GPA is higher than 1.0, Rule #3 applies, and the entire expression is evaluated as true (meaning the invariant is valid). context Student inv: self.gpa Extension < Mechanisms 1.0 IMPLIES self.yearofgraduation = 0000 OCL's boolean expressions are valid regardless of the order of the arguments. Specifically, if the first argument of an AND operator is undefined, but the second operator is false, the entire expression is false. Likewise, even if one of the arguments to an OR operator is undefined, if the other If you're is true, new the to UML, expression a tutorial is true. with If-then-else-endif realistic examples has constructs even been are included evaluated to similarly; help you if the chosen quickly branch familiarize can be yourself evaluated with to the TRue system. or false, the nonchosen branch is completely disregarded (even if it would be undefined). B.3.2. Variable Declaration

OCL supports several complex constructs you can use to make your constraints more expressive and easier to write. You can break complex expressions into reusable pieces (within the same UML 2.0 in a Nutshell expression) by using the let and in keywords to declare a variable. You declare a variable by giving it a name, By followed Dan Pilone, Neil by a Pitman colon (:), its type, an expression for its value, and the in keyword. The following example declares an expression that ensures a teacher of a high-level course has an appropriate salary: Pub Date: June 2005 context Course inv: let salary : float = self.instructor.salary in if self.courselevel > 4000 then Table of Contents salary Index > 80000.00 else salary < 80000.00 System endif developers have used modeling languages for decades to specify, visualize, construct, and document systems. The Unified Modeling Language (UML) is one of those languages. UML makes it possible for team members to collaborate by providing a common You language can define that applies variables to that a multitude can be used of different in multiple systems. expressions Essentially, on a it classifier-by-classifier enables you to basis using communicate the def keyword. solutions For in a example, consistent, instead tool-supported of declaring language. salary as a variable using the let keyword, you can define it using the def keyword for the Course context. Once you define a variable Today, UML using has the become def keyword, the standard you may method use that for variable modeling in software any expression systems, that which is in means the same context. you're probably The syntax confronting for the def this keyword rich and is expressive the same as language that for more the let than keyword: ever before. And diagrams context written Course by others. def: salary : float = self.instructor.salary So, now you can write the previous invariant as: types, context it also explains Course inv: key concepts in a way that appeals to readers already familiar with UML if or self.courselevel object-oriented programming > 4000 then concepts. salary > 80000.00 Topics gethonorsstudentselse include: salary < 80000.00 endif B.3.3. Operator Precedence OCL operators have the following order of precedence (from highest to lowest): @pre dot The (.) Object and arrow Constraint (->) operations Language (OCL) not and unary minus (-) If you're * and new / to UML, a tutorial with realistic examples has even been included to help you + and - if-then-else-endif <, >, <=, and >=

= and <> and, or, and xor UML 2.0 in a Nutshell implies You can use parentheses to group expressions, which will be evaluated from the innermost set of parentheses to the Pub Date: outermost. June 2005 B.3.4. Built-in Object Properties OCL provides a set of properties on all objects in a system. You can invoke these properties in your expressions as you do any other properties. The built-in properties are: construct, and document systems. The Unified Modeling Language (UML) is one of those oclistypeof languages. UML (t : makes Type) : it Boolean possible for team members to collaborate by providing a common language that applies to a multitude of different systems. Essentially, it enables you to communicate Returns true solutions if the in tested a consistent, object tool-supported exactly the same language. type as t. ocliskindof( you're probably t : confronting Type) : Boolean this rich and expressive language more than ever before. And diagrams Returns written TRue by if others. tested object is the same type or a subtype of t. oclinstate(s you who must : read, State create, ): Boolean and understand system artifacts expressed using UML. Returns TRue if the tested object is in state s. The states you can test must be part of a state This comprehensive machine attached new to edition the classifier not only being provides tested. a quick-reference to all UML 2.0 diagram oclisnew( ) : Boolean Topics Designed include: to be used in a postcondition for an operation, it returns true if the object being tested was created as a result of executing the operation. oclastype (t : Type) : Type Returns the owning object casted to Type. If the object isn't a descendant of t, the operation is undefined. Here are and some Deployment examples Diagrams of the built-in properties: -- Extension test that Mechanisms the instructor is an instance of Teacher context Course inv: The Object self.instructor.oclistypeof(teacher) Constraint Language (OCL) -- cast a Date class to a java.sql.date to verify the minutes -- (it's very unlikely the foundationdate would be a java.sql.date If you're -- so new this to UML, invariant a tutorial would with realistic be undefined, examples but has this even is been an included exampleto help you quickly -- familiarize of using yourself oclastype( with the )) system. context School inv: self.foundationdate.oclastype(java.sql.date).getminutes( ) = 0

B.3.5. Collections UML 2.0 in a Nutshell OCL defines several types of collections that represent several instances of a classifier. The basic type is Collection, which is the base class for the other OCL collection classes. Quite a few operations are defined for Collection; see the OCL specification for the complete list. Pub Date: June 2005 All collections support a way to select or reject elements using the operations select( ) and reject( ), respectively. To invoke an operation on a collection, you use an arrow (->) rather than a dot (.) (a dot accesses a property). The result of select or reject is another collection containing the appropriate elements. Remember that since OCL can't modify a system in any way, the original collection is unchanged. The notation for a select is: collection->select(boolean expression) construct, and document systems. The Unified Modeling Language (UML) is one of those So, languages. to select UML students makes with possible GPAs higher for team than members 3.0, you can to collaborate use the expression: by providing a common language that applies to a multitude of different systems. Essentially, it enables you to communicate solutions in a consistent, tool-supported language. context Course::getHonorsStudents( ) : Student body: self.students->select(gpa > 3.0) Or, diagrams to eliminate written honor by others. students that haven't paid their tuition: UML context 2.0 in a Nutshell Course::getHonorsStudents( from O'Reilly feels your pain. ) : It's Student been crafted for professionals like you body: who must self.students->select(gpa read, create, and understand > 3.0)->reject(tuitionPaid system artifacts expressed using = false) UML. In This the comprehensive previous examples, new edition the context not only for the provides select a and quick-reference reject statements to all UML was 2.0 implied. diagram You can explicitly types, it name also explains the element key concepts you want in to a use way in that the appeals boolean to expression readers already by prefixing familiar the with expression with UML a or label object-oriented and a pipe symbol programming ( ). So, concepts. a rewrite of the GPA example using a label to identify each student looks like this: context Course::getHonorsStudents( ) : Student body: The role self.students->select(curstudent and value of UML in projects curstudent.gpa > 3.0) Finally, you can specify the type of the element you want to evaluate. You indicate the type by placing An a integrated colon (:) and approach the classifier to UML type diagrams after the label. Each element of the collection you are evaluating must be of the specified type, or else the expression is undefined. You can rewrite the GPA example Class and to Object, be even Use more Case, specific Sequence, and require Collaboration, that it evaluate Statechart, only Students: Activity, Component, context Extension Course::getHonorsStudents( Mechanisms ) : Student body: self.students->select(curstudent : Student curstudent.gpa > 3.0) Often you will need to express a constraint across an entire collection of objects, so OCL provides the forall operation that returns true if a given Boolean expression evaluates to true for all of the elements in a collection. The syntax for forall is the same as that for select and reject. So, you can write a constraint that enforces that all students in a Course have paid their tuition: context Course inv: self.students->forall(tuitionpaid = true)

As you can with select, you can name and type the variable used in the expression: context Course UML 2.0 in a Nutshell inv: self.students->forall(curstudent : Student curstudent.tuitionpaid = true) If you need to check Pub Date: to see June if 2005 there is at least one element in a collection that satisfies a boolean expression, you ISBN: can use 0-596-00795-7 the operation exists. The syntax is the same as that for select. The following expression Pages: ensures 234 that at least one of the students has paid their tuition: context Course inv: self.students->exists(tuitionpaid = true) Like construct, select, and you document can name systems. and type The the variables Unified Modeling used in Language the expression: (UML) is one of those languages. UML makes it possible for team members to collaborate by providing a common language context that Course applies to a multitude of different systems. Essentially, it enables you to communicate inv: self.students->exists(curstudent solutions in a consistent, tool-supported : Student language. curstudent.tuitionpaid = true) You you're can probably check to confronting see if a collection this rich is and empty expressive using the language operations more isempty than or ever notempty. before. And The following even though expression you may ensures not write that UML the diagrams school has yourself, at least you'll one course still need offering: to interpret UML context 2.0 in a Nutshell School from O'Reilly feels your pain. It's been crafted for professionals like you inv: who must self.course->notempty( read, create, and understand ) system artifacts expressed using UML.