15
Main Page Table of content Copyright Praise for 'The Object Constraint Language, Second Edition' 'The Addison-Wesley Object Technology Series' 'The Component Software Series' List of Figures List of Tables Foreword to the First Edition Foreword to the Second Edition Preface and Introduction Who Should Read This Book How This Book Should Be Used Typeface Conventions Information on Related Subjects Acknowledgments Part 1: User Manual Chapter 1. MDA and the Use of OCL 1.1 Introducing OCL 1.2 Model Driven Architecture 1.3 Modeling Maturity Levels 1.4 Building Better Models 1.5 Characteristics of OCL 1.6 Summary Chapter 2. OCL By Example 2.1 The 'Royal and Loyal' System Example 2.2 Adding Extra Information 2.3 Adding Invariants 2.4 Working with Collections of Objects 2.5 Adding Preconditions and Postconditions

Jos Warmer, Anneke Kleppe Object Constraint Language, The Getting Your Models Ready for MDA 2003

Embed Size (px)

Citation preview

Page 1: Jos Warmer, Anneke Kleppe Object Constraint Language, The Getting Your Models Ready for MDA 2003

Main Page Table of content Copyright Praise for 'The Object Constraint Language, Second Edition' 'The Addison-Wesley Object Technology Series' 'The Component Software Series' List of Figures List of Tables Foreword to the First Edition Foreword to the Second Edition Preface and Introduction Who Should Read This Book How This Book Should Be Used Typeface Conventions Information on Related Subjects Acknowledgments Part 1: User Manual Chapter 1. MDA and the Use of OCL 1.1 Introducing OCL 1.2 Model Driven Architecture 1.3 Modeling Maturity Levels 1.4 Building Better Models 1.5 Characteristics of OCL 1.6 Summary Chapter 2. OCL By Example 2.1 The 'Royal and Loyal' System Example 2.2 Adding Extra Information 2.3 Adding Invariants 2.4 Working with Collections of Objects 2.5 Adding Preconditions and Postconditions

Page 2: Jos Warmer, Anneke Kleppe Object Constraint Language, The Getting Your Models Ready for MDA 2003

2.6 Taking Inheritance into Account 2.7 Comments 2.8 Let Expressions 2.9 Summary Chapter 3. Building Models with OCL 3.1 What Is a Model? 3.2 Use UML Diagrams as a Base 3.3 Completing Class Diagrams 3.4 Completing Interaction Diagrams 3.5 Completing Statecharts 3.6 Completing Activity Diagrams 3.7 Completing Component Diagrams 3.8 Completing Use Cases 3.9 Modeling Styles 3.10 Tips and Hints 3.11 Summary Chapter 4. Implementing OCL 4.1 Implementation Process 4.2 Implementing UML Model Elements 4.3 Implementing the OCL Standard Library 4.4 Implementing OCL Expressions 4.5 Merging Code Fragments 4.6 Considerations for Constraints 4.7 Summary Chapter 5. Using OCL for MDA 5.1 Relation of OCL to MDA 5.2 Metamodels 5.3 The OCL and UML Metamodels 5.4 Using OCL to Define Languages 5.5 Using OCL to Define Transformations 5.6 Summary

Page 3: Jos Warmer, Anneke Kleppe Object Constraint Language, The Getting Your Models Ready for MDA 2003

Part 2: Reference Manual Chapter 6. The Context of OCL Expressions 6.1 A Combined Model 6.2 Classes and Other Types 6.3 Attributes and Association Ends 6.4 Operations 6.5 Expressions in Behavior Diagrams 6.6 Use Cases 6.7 Constraints and Inheritance Chapter 7. Basic OCL Elements 7.1 Expressions, Types, and Values 7.2 Basic Types and Operators 7.3 Precedence Rules 7.4 Use of Infix Operators 7.5 Comments Chapter 8. User-defined Types 8.1 Features of User-Defined Types 8.2 Associations and Aggregations 8.3 Enumeration Types Chapter 9. Collection Types 9.1 The Collection Types 9.2 Operations on Collection Types 9.3 Loop Operations or Iterators Chapter 10. Advanced Constructs 10.1 Constructs for Postconditions 10.2 Operations of the 'OclMessage' Type 10.3 Packaging Expressions 10.4 Local Variables 10.5 Tuples and Tuple Types 10.6 Undefined Values, the 'OclVoid' Type 10.7 Retyping or Casting

Page 4: Jos Warmer, Anneke Kleppe Object Constraint Language, The Getting Your Models Ready for MDA 2003

10.8 Type Conformance Rules 10.9 Accessing Overriden Features 10.10 The 'OclAny' Type Appendix A. Glossary Glossary Appendix B. OCL Grammar Rules B.1 EBNF Rules for Context Declaration B.2 EBNF Rules for Expression Appendix C. A Business Modeling Syntax for OCL C.1 Introduction C.2 Informal Definition C.3 Some Remarks on the Resemblance to SQL C.4 More Elaborate Examples Appendix D. Example Implementation Appendix E. Differences Between OCL Versions 1.1 and 2.0 E.1 Syntax Changes E.2 New Types E.3 Extra Predefined Operations E.4 New Options in Postconditions E.5 Other Changes Bibliography Index Index SYMBOL Index A Index B Index C Index D Index E Index F Index G Index H

Page 5: Jos Warmer, Anneke Kleppe Object Constraint Language, The Getting Your Models Ready for MDA 2003

Index I Index J Index L Index M Index N Index O Index P Index Q Index R Index S Index T Index U Index V

Page 6: Jos Warmer, Anneke Kleppe Object Constraint Language, The Getting Your Models Ready for MDA 2003

• Table of Contents• Index

Object Constraint Language, The: GettingYour Models Ready for MDA, SecondEditionBy Jos Warmer, Anneke Kleppe Publisher : Addison WesleyPub Date : August 29, 2003

ISBN : 0-321-17936-6Pages : 240

"In this thoroughly revised edition, Jos and Annekeoffer a concise, pragmatic, and pedagogic explanationof the Object Constraint Language (OCL) and itsdifferent applications. Their discussion of OCL'spotential role in Model Driven Architecture (MDA) istimely and offers great insight into the way that UMLcan be taken to the next level of automated softwaredevelopment practice. I highly recommend this book toanyone who is looking to get the most out of UML"-Shane Sendall, Ph.D.Senior ResearcherSwiss FederalInstitute of Technology in Lausanne

The release of Unified Modeling Language (UML) 2.0

Page 7: Jos Warmer, Anneke Kleppe Object Constraint Language, The Getting Your Models Ready for MDA 2003

places renewed emphasis on the Object ConstraintLanguage (OCL). Within UML, OCL is the standard forspecifying expressions that add vital information toobject-oriented models and other object-modelingartifacts. Model-Driven Architecture (MDA) relies onOCL to add the level of programming detail necessaryto enable Platform-Specific Models (PSM) tocommunicate with Platform-Independent Models (PIM).

This book is a practical, accessible guide to OCL forsoftware architects, designers, and developers. Muchcare has been taken during the redesign of OCL toensure that the syntax remains readable and writableby the average software modeler. The Object ConstraintLanguage, Second Edition, utilizes a case study to showhow to exercise these compact but powerfulexpressions for maximum effect.

This newly updated edition also

Explains why OCL is critical to MDA-and why UMLalone is not enough

Introduces an SQL-like syntax to OCL

Defines the new language constructs of OCL 2.0

Demonstrates how OCL can be incorporated intocode

Shares tips and tricks for applying OCL to real-worldmodeling challenges-showing which can be solved

Page 8: Jos Warmer, Anneke Kleppe Object Constraint Language, The Getting Your Models Ready for MDA 2003

with UML and which require OCL

Using a combination of UML and OCL allows developersto realize the effective, consistent, and coherentmodels that are critical to working with MDA. Theauthors' pragmatic approach and illustrative use ofexamples will help application developers come quicklyup to speed with this important object-modelingmethod--and will serve as a ready reference thereafter.

Page 9: Jos Warmer, Anneke Kleppe Object Constraint Language, The Getting Your Models Ready for MDA 2003

• Table of Contents• Index

Object Constraint Language, The: GettingYour Models Ready for MDA, SecondEditionBy Jos Warmer, Anneke Kleppe Publisher : Addison WesleyPub Date : August 29, 2003

ISBN : 0-321-17936-6Pages : 240

Copyright Praise for The Object Constraint Language, Second Edition The Addison-Wesley Object Technology Series The Component Software Series List of Figures List of Tables Foreword to the First Edition Foreword to the Second Edition Preface and Introduction Who Should Read This Book

How This Book Should Be Used

Typeface Conventions

Information on Related Subjects

Acknowledgments

Part 1. User Manual Chapter 1. MDA and the Use of OCL

Section 1.1. Introducing OCL

Section 1.2. Model Driven Architecture

Section 1.3. Modeling Maturity Levels

Section 1.4. Building Better Models

Section 1.5. Characteristics of OCL

Page 10: Jos Warmer, Anneke Kleppe Object Constraint Language, The Getting Your Models Ready for MDA 2003

Section 1.6. Summary

Chapter 2. OCL By Example

Section 2.1. The "Royal and Loyal" System Example

Section 2.2. Adding Extra Information

Section 2.3. Adding Invariants

Section 2.4. Working with Collections of Objects

Section 2.5. Adding Preconditions and Postconditions

Section 2.6. Taking Inheritance into Account

Section 2.7. Comments

Section 2.8. Let Expressions

Section 2.9. Summary

Chapter 3. Building Models with OCL

Section 3.1. What Is a Model?

Section 3.2. Use UML Diagrams as a Base

Section 3.3. Completing Class Diagrams

Section 3.4. Completing Interaction Diagrams

Section 3.5. Completing Statecharts

Section 3.6. Completing Activity Diagrams

Section 3.7. Completing Component Diagrams

Section 3.8. Completing Use Cases

Section 3.9. Modeling Styles

Section 3.10. Tips and Hints

Section 3.11. Summary

Chapter 4. Implementing OCL

Section 4.1. Implementation Process

Section 4.2. Implementing UML Model Elements

Section 4.3. Implementing the OCL Standard Library

Section 4.4. Implementing OCL Expressions

Section 4.5. Merging Code Fragments

Section 4.6. Considerations for Constraints

Section 4.7. Summary

Chapter 5. Using OCL for MDA

Section 5.1. Relation of OCL to MDA

Section 5.2. Metamodels

Section 5.3. The OCL and UML Metamodels

Section 5.4. Using OCL to Define Languages

Section 5.5. Using OCL to Define Transformations

Section 5.6. Summary

Part 2. Reference Manual Chapter 6. The Context of OCL Expressions

Section 6.1. A Combined Model

Section 6.2. Classes and Other Types

Section 6.3. Attributes and Association Ends

Section 6.4. Operations

Page 11: Jos Warmer, Anneke Kleppe Object Constraint Language, The Getting Your Models Ready for MDA 2003

Section 6.5. Expressions in Behavior Diagrams

Section 6.6. Use Cases

Section 6.7. Constraints and Inheritance

Chapter 7. Basic OCL Elements

Section 7.1. Expressions, Types, and Values

Section 7.2. Basic Types and Operators

Section 7.3. Precedence Rules

Section 7.4. Use of Infix Operators

Section 7.5. Comments

Chapter 8. User-defined Types

Section 8.1. Features of User-Defined Types

Section 8.2. Associations and Aggregations

Section 8.3. Enumeration Types

Chapter 9. Collection Types

Section 9.1. The Collection Types

Section 9.2. Operations on Collection Types

Section 9.3. Loop Operations or Iterators

Chapter 10. Advanced Constructs

Section 10.1. Constructs for Postconditions

Section 10.2. Operations of the OclMessage Type

Section 10.3. Packaging Expressions

Section 10.4. Local Variables

Section 10.5. Tuples and Tuple Types

Section 10.6. Undefined Values, the OclVoid Type

Section 10.7. Retyping or Casting

Section 10.8. Type Conformance Rules

Section 10.9. Accessing Overriden Features

Section 10.10. The OclAny Type

Appendix A. Glossary

Glossary

Appendix B. OCL Grammar Rules

Section B.1. EBNF Rules for Context Declaration

Section B.2. EBNF Rules for Expression

Appendix C. A Business Modeling Syntax for OCL

Section C.1. Introduction

Section C.2. Informal Definition

Section C.3. Some Remarks on the Resemblance to SQL

Section C.4. More Elaborate Examples

Appendix D. Example Implementation

Appendix E. Differences Between OCL Versions 1.1 and 2.0

Section E.1. Syntax Changes

Section E.2. New Types

Section E.3. Extra Predefined Operations

Page 12: Jos Warmer, Anneke Kleppe Object Constraint Language, The Getting Your Models Ready for MDA 2003

Section E.4. New Options in Postconditions Section E.5. Other Changes

Bibliography Index

Page 13: Jos Warmer, Anneke Kleppe Object Constraint Language, The Getting Your Models Ready for MDA 2003

CopyrightMany of the designations used by manufacturers and sellers to distinguishtheir products are claimed as trademarks. Where those designations appear inthis book, and Addison-Wesley was aware of a trademark claim, thedesignations have been printed with initial capital letters or in all capitals.

MDA® is a registered trademark of Object Management Group, Inc. in theUnited States and/or other countries.

The authors and publisher have taken care in the preparation of this book, butmake no expressed or implied warranty of any kind and assume noresponsibility for errors or omissions. No liability is assumed for incidental orconsequential damages in connection with or arising out of the use of theinformation or programs contained herein.

The publisher offers discounts on this book when ordered in quantity for bulkpurchases and special sales. For more information, please contact:

U.S. Corporate and Government Sales (800) 382-3419 [email protected]

For sales outside of the U.S., please contact:

International Sales (317) 581-3793 [email protected]

Library of Congress Cataloging-in-Publication Data

Warmer, Jos B. The object constraint language : getting your models ready for MDA / Jos Warmer, Anneke Kleppe. p. cm.Includes bibliographical references and index.ISBN 0-321-17936-6 1. Object-oriented methods (Computer science) 2. UML (Computer science) I. Kleppe, Anneke G. II. Title.

QA76.9.O35W35 2003005.1'17--dc22 2003057724

Page 14: Jos Warmer, Anneke Kleppe Object Constraint Language, The Getting Your Models Ready for MDA 2003

Copyright © 2003 by Pearson Education, Inc.

All rights reserved. No part of this publication may be reproduced, stored in aretrieval system, or transmitted, in any form, or by any means, electronic,mechanical, photocopying, recording, or otherwise, without the prior consentof the publisher. Printed in the United States of America. Publishedsimultaneously in Canada.

For information on obtaining permission for use of material from this work,please submit a written request to:

Pearson Education, Inc. Rights and Contracts Department 75 Arlington Street, Suite 300 Boston, MA 02116 Fax: (617) 848-7047

Text printed on recycled paper

1 2 3 4 5 6 7 8 9 10-CRS-0706050403

First printing, August 2003

Page 15: Jos Warmer, Anneke Kleppe Object Constraint Language, The Getting Your Models Ready for MDA 2003

Praise for The Object Constraint Language, SecondEdition

"In this thoroughly revised edition, Jos and Anneke offer a concise,pragmatic, and pedagogic explanation of the Object Constraint Language(OCL) and its different applications. Their discussion of OCL's potentialrole in Model Driven Architecture (MDA) is timely and offers great insightinto the way that UML can be taken to the next level of automatedsoftware development practice. I highly recommend this book to anyonewho is looking to get the most out of UML."

Shane Sendall,PhD Senior ResearcherSwiss Federal Institute of Technology, Lausanne

"MDA promises a revolution in the way we develop software. This book isessential reading for anyone intending to adopt MDA technology."

Tony Clark,PhD King's College, London

"Through examples, Jos and Anneke demonstrate the power andintuitiveness of OCL, and the key role that this language plays inimplementing and promoting MDA. The theme, structure, contents, and,not lastly, the clarity of explanations recommend this book as the bestadvocate for learning, using, and promoting OCL, UML, and MDA. I amsure that this work will contribute in a significant manner to thedevelopment and widespread use of new software technologies."

Dan ChioreanHead of the Computer Science Research LaboratoryBabes-Bolyai University, Cluj