UML Model architecture Object Constraint Language

Slides:



Advertisements
Similar presentations
Formal Methods of Systems Specification Logical Specification of Hard- and Software Dr. Armin Wolf Fraunhofer Institut für Rechnerarchitektur.
Advertisements

Language Specification using Metamodelling Joachim Fischer Humboldt University Berlin LAB Workshop Geneva
The role of OCL in the Model Driven Architecture Jos Warmer Klasse Objecten
UML an overview.
Semantics Static semantics Dynamic semantics attribute grammars
OCL2 April A presentation of OCL 2 Object Constraint Language Christian Hein, Fraunhofer FOKUS April 2006.
ISBN Chapter 3 Describing Syntax and Semantics.
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
Describing Syntax and Semantics
Object Oriented Databases - Overview
Visualization By: Simon Luangsisombath. Canonical Visualization  Architectural modeling notations are ways to organize information  Canonical notation.
Specifications Liskov Chapter 9 SWE 619 Last Updated Fall 2008.
SEG4110 – Advanced Software Engineering and Reengineering TOPIC E Object Constraint Language (OCL)
Ranga Rodrigo. Class is central to object oriented programming.
DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model.
Ontology Development Kenneth Baclawski Northeastern University Harvard Medical School.
1 COSC 4406 Software Engineering COSC 4406 Software Engineering Haibin Zhu, Ph.D. Dept. of Computer Science and mathematics, Nipissing University, 100.
111 Writing Protocols in OCL CS 4311 Jos B. Warmer and Anneke G. Kleppe, OCL: The Constraint Language of the UML, JOOP, May Jos B. Warmer and Anneke.
UML Model architecture Object Constraint Language Lectures P9-P11 T120B pavasario sem.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Slides for Gregor Kiczales Two versions –short version: Crosscutting capabilities for Java and AspectJ through DJ (4 viewgraphs only) –long version: Controlling.
Not only mark-up languages! There are other many other grammar formalisms and tools than XML. Some of them standardized (ASN). Even XML does not always.
1 OCL The Role of OCL in UML. 2 רשימת הנושאים  מבוא  מרכיבי השפה  דוגמאות  מקורות.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
Drawbacks of object-oriented software development Lecture P12 T120B pavasario sem.
Sheet 1 DocEng’03, Grenoble, November 2003 Model Driven Architecture based XML Processing Ivan Kurtev, Klaas van den Berg University of Twente, the Netherlands.
IM NTU Software Development Methods, Fall2006 Software Development Methods, Fall 2006 OCL 2006/12/ Object Constraint Language (OCL) Yih-Kuen Tsay.
Design Model Lecture p6 T120B pavasario sem.
Chapter 3 Part II Describing Syntax and Semantics.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Object Constraint Language
1 Kyung Hee University Constraints Spring Kyung Hee University Graphical Notations  Graphical notations are well suited for displaying structural.
1 Class Diagrams. 2 Overview Class diagrams are the most commonly used diagrams in UML. Class diagrams are for visualizing, specifying and documenting.
Software Engineering 2 -Prakash Shrestha.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
UML Profile BY RAEF MOUSHEIMISH. Background Model is a description of system or part of a system using well- defined language. Model is a description.
Object-Oriented Software Engineering Practical Software Development using UML and Java Modelling with Classes.
Interpreting the Object Constraint Presented by: Ed Kausmeyer.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
A UML-Based Pattern Specification Technique Presented by Chin-Yi Tsai IEEE TRANSACTION ON SOFTWARE ENGINEERING, VOL. 30, NO. 3, MARCH 2004 Robert B. France,
ALLOY: A Formal Methods Tool Glenn Gordon Indiana University of Pennsylvania COSC 481- Formal Methods Dr. W. Oblitey 26 April 2005.
Jan Pettersen Nytun, UIA, page 1. Jan Pettersen Nytun, UIA, page 2 HISTORY COLLECTION TYPES AND QUERING IN OCL FORMAL LANGUAGE - STATEMENT EXAMPLES CONSTRAINTS.
Language = Syntax + Semantics + Vocabulary
Crosscutting Capabilities for Java and AspectJ through DJ
Course Outcomes of Object Oriented Modeling Design (17630,C604)
Extending UML.
SysML v2 Formalism: Requirements & Benefits
Arab Open University 2nd Semester, M301 Unit 5
Specifications Liskov Chapter 9
The Object Constraint Language
Chapter 12 Outline Overview of Object Database Concepts
Relational Algebra Chapter 4, Part A
Component-Level Design
ADAPTIVE PROGRAMMING Sezen ERDEM December 2005.
Component-Level Design
Review lecture AOO/Demeter.
UML: Unified Modeling Language
Chapter 20 Object-Oriented Analysis and Design
A Specification Language
Midterm Review CSU 670 Spring 2004.
Semantics In Text: Chapter 3.
Analysis models and design models
Class Diagrams.
An Introduction to Software Architecture
The Object Constraint Language
Formal Methods in Software Engineering 1
Generics, Lambdas and Reflection
Software Architecture & Design
Presentation transcript:

UML Model architecture Object Constraint Language Lecture 9 UML Model architecture Object Constraint Language 9/22/2018 AOO / UML / OCL/Strategies

UML language architecture UML metamodel defines meaning of UML models Defined in a metacircular manner, using a subset of UML to specify itself UML metamodel bootstraps itself. Similar: compiler compiles itself grammar defines itself class dictionary defines itself 9/22/2018 AOO / UML / OCL/Strategies

4 layer metamodel architecture UML metamodel one of the layers Why four layers? Proven architecture for complex models Validates core constructs by using them to define themselves 9/22/2018 AOO / UML / OCL/Strategies

Four layer architecture meta-metamodel language for specifying metamodels metamodel language for specifying models model language for specifying objects in some domain user objects 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Four levels User Objects in running system check run-time constraints Model of System under design specify run-time constraints Meta-model specify constraints on use of constructs in model Meta-metamodel data interchange between modeling tools 9/22/2018 AOO / UML / OCL/Strategies

Three layers of Demeter instance of defines classes Demeter behavior and aspect files B: metamodel L: model P: user objects CB your behavior and aspect files CL metamodel OB classes model OL TB user object OP a class dictionary for class dictionaries objects TL class dictionary TP text sentence 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Icon Demeter Tiling Use as reminder for Demeter Tiling. CB OB CL TB OL TL OP TP 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Object Constraint Language allows you to define side effect-free constraints for UML and other models (for example adaptive programs) used in UML to defined well-formedness rules of the UML meta model (invariants for meta model classes) 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Why OCL It is a formal mathematical language Tend to be hard to use by average modelers OCL is intended for average modelers Developed as business modeling language within IBM insurance division (has roots in Syntropy method) OCL is a pure expression language (side effect free) 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Companies behind OCL Rational Software, Microsoft, Hewlett-Packard, Oracle, Sterling Software, MCI Systemhouse, Unisys, ICON Computing, IntelliCorp, i-Logix, IBM, ObjecTime, Platinum Technology, Ptech, Taskon, Reich Technologies, Softeam 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Where to use OCL? Specify invariants for classes and types Specify pre- and post-conditions for methods As a navigation language 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies OCL properties LL(1) language finally back to the Pascal days! Grammar provided uses EBNF syntax Parser generated by JavaCC 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies What is OCL? Predicate calculus for objects Traditional predicate calculus: individuals variables, predicate and function symbols terms (for all, Boolean connectives) axioms and the theories they define (group theory, number theory, etc.) In OCL: individuals -> objects 9/22/2018 AOO / UML / OCL/Strategies

Structured individuals some “structural” constraints imposed by UML class diagram; further constraints can be imposed by OCL expressions annotated UML class diagram defines textual representation 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Connection to model Self. Each OCL expression is written in the context of an instance of a specific type. Company self.numberOfEmployees c : Company c.numberOfEmployees 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Connection to model Invariants of a type. An OCL expression stereotyped with <<invariant>>. An invariant must be true for all instances of the type at any time. Person <<invariant>> self.age >= 0 9/22/2018 AOO / UML / OCL/Strategies

Example: UML class diagram ClassGraph 0..* Entry EParse entries ClassGraph Note: we use a thick arrow to denote inheritance. UML uses an open arrow. ClassDef BParse Body parts Part className 0..* super ClassName Concrete Abstract 9/22/2018 AOO / UML / OCL/Strategies

UML class diagram ClassGraph 0..* Entry EParse entries ClassGraph BParse ClassDef Body parts Part className 0..* ClassName number of concrete classes super Concrete Abstract 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Example -> collection op select:subset collect:new set Number of concrete classes: ClassGraph self.entries-> select(c:Entry|c. oclIsTypeOf(ClassDef))-> collect(body)-> select (b:Body|b. oclIsTypeOf(Concrete)) ->size 9/22/2018 AOO / UML / OCL/Strategies

Pre- and post-conditions constraints stereotyped with <<precondition>> and <<postcondition>> for an operation or method. Example: Type::op(param1 : Type1 …): ReturnType <<pre>>: param1 … <<post>>: result = … 9/22/2018 AOO / UML / OCL/Strategies

Pre- and post-conditions Example: Post condition for insert operation: person.allInstances -> forAll(p1, p2 | p1 <> p2 implies p1.id <> p2.id) 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Basic values and types Boolean true, false and or xor not implies if-then-else Integer 1 2 3 subtype of Real * + - / abs Real 3.14 * + - / floor String ‘To be or not to be’ toUpper concat 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Basic values and types Collection Set subtype of Collection Sequence subtype of Collection Bag subtype of Collection if element types conform to each other 9/22/2018 AOO / UML / OCL/Strategies

Types from the UML Model Each OCL expression lives in the context of a UML model, a number of types/classes and their features and associations and their generalizations. All types/classes from the UML model are types in OCL. 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Type Conformance OCL is typed Type conformance rules for types in the class diagram are simple: each type conforms to its supertype type conformance is transitive 9/22/2018 AOO / UML / OCL/Strategies

Objects and properties The value of a property on an object that is defined in a class diagram is specified by a dot followed by the property name. Atype self.property 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Properties an attribute an association end an operation with isQuery true a method with isQuery true 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Properties an attribute Person self.age >= 0 self.employer->size an association end Company self.manager --type Person self.employee--type Set(Person) 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Properties an operation with isQuery true Person self.income(aDate) Company self.stockPrice() 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Missing role names Whenever a role name is missing at one of the ends of an association, the name of the type at the association end, starting with a lowercase character is used as role name. If this results in an ambiguity, the role name is mandatory 9/22/2018 AOO / UML / OCL/Strategies

Navigation over associations Company self.manager object of type Person or Set(Person) used as Set(Person) self.manager->size -- result 1 used as Person self.manager.age 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies OclType and OclAny All types in a UML model, or predefined within UML have a type. This type is an instance of the OCL type called OclType. OclType: meta type of all types. OclAny supertype of all types. OclType : Class = OclAny : Object (analogy to Java) Features of OclType: good for meta programming. 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Predefined OCL types OclType: type: instance of OclType type.name : String type.attributes:Set(String) type.associationEnds:Set(String) type.operations:Set(String) type.supertypes:Set(OclType) type.allSupertypes:Set(OclType) type.allInstances:Set(type) 9/22/2018 AOO / UML / OCL/Strategies

Similarity: java.lang.Class instances of class Class represent classes and interfaces in a way that can be read (but not modified) by a running Java program public final class Class{ public String getName(); public Class getSuperClass(); public Class[] getInterfaces(); ... 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Predefined OCL types OclAny: supertype of all types in the model. object: instance of OclAny object=(object2:OclAny) object<>(object2:OclAny):Boolean object.oclType:OclType object.oclIsKindOf(type:OclType): Boolean 9/22/2018 AOO / UML / OCL/Strategies

Similarity: java.lang.Object All objects, including arrays, implement the methods of this class public class Object { public final Class getClass(); public boolean equals(Object obj); ... 9/22/2018 AOO / UML / OCL/Strategies

Predefined features on all objects (OclAny) Type of an object oclType : OclType Feature oclType results in type of an object Direct type oclIsTypeOf(t:OclType):Boolean Direct or super type oclIsKindOf(t:OclType):Boolean 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Examples Person self.oclType results in Person self.oclIsTypeOf(Person)--true self.oclIsTypeOf(Company)--false 9/22/2018 AOO / UML / OCL/Strategies

Predefined features on types Two kinds of properties on instances of classes on types/classes themselves Most important predefined feature on each type: allInstances Person.allInstances -> forAll(p1, p2 | p1 <> p2 implies p1.id <> p2.id) 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Collections Navigation will most often result in a collection. Collection predefined Large number of predefined operations Collection(X) : Set(X)|Sequence(X)|Bag(X). Specifiable by a literal 9/22/2018 AOO / UML / OCL/Strategies

Collection type conformance Collection(X) is a subtype of OclAny. Rules (only number 3 collection specific) T1 conforms to T2 if T1=T2. T1 conforms to T2 when T1 is a subtype of T2. Collection(T1) conforms to Collection(T2) if T1 conforms to T2 conformance is transitive 9/22/2018 AOO / UML / OCL/Strategies

Previous value in post-conditions Pre- and post-conditions on operations and methods the value of a property at the start of the operation or method the value of a property upon completion of the operation or method Person::birthdayHappens() post: age = age@pre + 1 9/22/2018 AOO / UML / OCL/Strategies

Collection Operations Select and reject operations collection->select(boolean-expr) Company self.employee->select(age > 50) collection->select (v|boolean-expr-with-v) Company self.employee->select (p|p.age > 50) 9/22/2018 AOO / UML / OCL/Strategies

Collection Operations Select and reject operations collection->select (v:Type|boolean-expr-with-v) Company self.employee->select (p:Person|p.age > 50) 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Select syntax Define a subset collection->select (v:Type|boolean-expr-with-v) (v|boolean-expr-with-v) (boolean-expr) type redundancy refer to entire object refer to parts 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Reject syntax Define a subset collection->reject (v:Type|boolean-expr-with-v) (v|boolean-expr-with-v) (boolean-expr) Instead negate expression 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Collect syntax collection->collect (v:Type|expr-with-v) (v|expr-with-v) (expr) Creates a bag self.empl->collect(bdate)->asSet Build new collection by applying expression to elements of old 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Shorthand for Collect Because navigation through many objects is very common, there is a shorthand notation for collect that makes OCL expressions more readable. Both are correct: self.employee -> collect(birthdate.year) self.employee.birthdate.year Violations of Law of Demeter! 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies ForAll operation All elements satisfy Boolean expression collection->forAll (v:Type|boolean-expr-with-v) (v|boolean-expr-with-v) (boolean-expr) 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Exists operation At least one element satisfies Boolean expression collection->exists (v:Type|boolean-expr-with-v) (v|boolean-expr-with-v) (boolean-expr) 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Predefined OCL types Integer, Real, String, Boolean OclExpression, OclType, OclAny OclType all types defined in a model have type OclType allows access to the meta-level of the model 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Predefined OCL types OclType: type: instance of OclType type.name : String type.attributes:Set(String) type.associationEnds:Set(String) type.operations:Set(String) type.supertypes:Set(OclType) type.allSupertypes:Set(OclType) type.allInstances:Set(type) 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Predefined OCL types OclAny: supertype of all types in the model. object: instance of OclAny object=(object2:OclAny) object<>(object2:OclAny):Boolean object.oclType:OclType object.oclIsKindOf(type:OclType): Boolean 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Applications Number of class definitions: ClassGraph self.entries->size wrong ClassGraph self.entries-> select(c:Entry|c. oclIsTypeOf(ClassDef))->size 0..* Entry EParse entries ClassGraph BParse ClassDef 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Applications Number of class definitions: What about using strategies to define collections? ClassGraph self.{to ClassDef} ->size 0..* Entry EParse entries ClassGraph BParse ClassDef 9/22/2018 AOO / UML / OCL/Strategies

Improve OCL: make adaptive OCL stresses the importance of collections Collections are best specified adaptively A strategy SS = (S, B, s, t) with source s and target set t and name map N for class graph G defines a collection of objects contained in a N(s)-object. The collection type CT is the union of N(t1) for t1 in t. 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Improve OCL The collection consists of CT-objects reached during the traversal of the N(s) object following strategy SS. 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Properties In OCL an attribute an association end an operation with isQuery true a method with isQuery true Add for adaptive OCL a strategy { … } with a single source 9/22/2018 AOO / UML / OCL/Strategies

UML class diagram ClassGraph 0..* Entry EParse entries ClassGraph BParse ClassDef Body parts Part className 0..* ClassName super ClassGraph -- concrete classes self.{to Concrete}->size Concrete Abstract 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Applications Number of concrete classes: ClassGraph self.entries-> select(c:Entry|c. oclIsTypeOf(ClassDef))-> collect(body)-> select (b:Body|b. oclIsTypeOf(Concrete)) ->size 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies ClassGraph self.entries-> select(c:Entry|c. oclIsTypeOf(ClassDef))-> collect(body)-> select (b:Body|b. oclIsTypeOf(Concrete)) ->size -- count concrete classes ClassGraph -- count concrete classes self.{to Concrete}->size Which one is easier to write? 9/22/2018 AOO / UML / OCL/Strategies

UML class diagram ClassGraph 0..* Entry EParse entries ClassGraph BParse ClassDef Body parts Part className 0..* ClassName super Concrete Abstract 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Applications Terminal buffer rule ClassGraph self.{to ClassDef} ->forAll(r|r.termBProp()) ClassDef Boolean termBProp(){ partCNs=self.{via Part to ClassName}; result=if (partCNs->size)>1 then (partCNs->intersection(predefCNs)) -> isEmpty else true endif} 9/22/2018 AOO / UML / OCL/Strategies

UML class diagram ClassGraph 0..* Entry EParse entries ClassGraph BParse ClassDef Body parts Part className 0..* ClassName super Concrete Abstract 9/22/2018 AOO / UML / OCL/Strategies

UML class diagram ClassGraph 0..* Entry EParse entries ClassGraph BParse ClassDef Body parts Part className 0..* ClassName super Concrete Abstract 9/22/2018 AOO / UML / OCL/Strategies

UML class diagram ClassGraph 0..* Entry EParse entries ClassGraph BParse ClassDef Body parts Part className 0..* ClassName super Concrete Abstract 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Applications Class graph is flat ClassGraph self.{to Abstract}-> forAll(a|a.parts->size=0) 9/22/2018 AOO / UML / OCL/Strategies

UML class diagram ClassGraph 0..* Entry EParse entries ClassGraph BParse ClassDef Body parts Part className 0..* ClassName super Concrete Abstract 9/22/2018 AOO / UML / OCL/Strategies

UML class diagram ClassGraph 0..* Entry EParse entries ClassGraph BParse ClassDef Body parts Part className 0..* ClassName super Concrete Abstract 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Applications Abstract superclass rule ClassGraph superCls = self.{through->*,super,* to ClassName}; self.{to ClassDef}-> forAll(c| if (superCls->includes(c.className)) then c.{to Abstract}->size=1 else true endif) 9/22/2018 AOO / UML / OCL/Strategies

UML class diagram ClassGraph 0..* Entry EParse entries ClassGraph BParse ClassDef Body parts Part className 0..* ClassName super Concrete Abstract 9/22/2018 AOO / UML / OCL/Strategies

UML class diagram ClassGraph 0..* Entry EParse entries ClassGraph BParse ClassDef Body parts Part className 0..* ClassName super Concrete Abstract 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Conclusions OCL is a suitable language for expressing object properties, class invariants and method pre- and post-conditions. (needs capability to define functions and auxiliary variables). OCL is NOT a good language for navigation but can be made into one by adding strategies. 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Further information www.rational.com contains latest information about UML, specifically OCL. www.ics.uci.edu/pub/arch/uml 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Context switch 9/22/2018 AOO / UML / OCL/Strategies

Drawbacks of object-oriented software development programs are tangled and redundant object-structure tangling, encoded repeatedly synchronization tangling distribution tangling programs are hard to maintain and too long because of tangling and redundancy 9/22/2018 AOO / UML / OCL/Strategies

Eliminating drawbacks with adaptive software Adaptive software is software which adjusts automatically to changing contexts/aspects. Contexts: object structure, object marshalling, synchronization, exceptions etc. Solution: Split software into cooperating, loosely coupled context- or aspect-descriptions. Strategies refer to structure. 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies What is Demeter A high-level interface to object-oriented programming and specification systems Demeter System/OPL = Demeter Method + Demeter Tools/OPL So far: OPL = {Java, C++, Perl, Borland Pascal, Flavors} Demeter Tools/OPL = Demeter/OPL 9/22/2018 AOO / UML / OCL/Strategies

Also useful for specification UML OCL = Unified Modeling Language Object Constraint Language (an OMG (= Object Management Group) standard) 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Risks of adaptive OO Advantages: Simpler programs for next project (compensates for learning curve). Programs are easier to evolve and maintain. Disadvantages: Additional training costs. New concepts, debugging techniques and tools to learn. 9/22/2018 AOO / UML / OCL/Strategies

Experience regarding training costs GTE project which took approximately four man months by non-adaptive techniques, took only 7 days to complete with adaptive techniques (using Demeter/Java). Our experience with Demeter/C++ is that the first project also has a shorter development time and maintenance is much simpler. 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Scenarios Best: Use Demeter/Java for future projects. Build library of adaptive components. Reduce software development and maintenance costs significantly. Worst: Use Demeter/Java only to generate Java code, but then you maintain Java code manually. You still win since a lot of useful Java code is produced. 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies History Hades (HArdware DEScription language by Niklaus Wirth at ETH Zurich) Zeus (a brother of Hades, a silicon compilation language at Princeton University/MIT, implemented at GTE Labs; predecessor of VHDL) Demeter (a sister of Zeus, used to implement Zeus, started at GTE Labs) 1982 82-85 1985- 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Data bases AP and object-oriented data bases design rules for class dictionaries persistence query languages P3 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Normalization Functional dependency A part V1 of some class C is functionally dependent on some part V2 if for all instances of class C each value of V2 has no more than one value of V1 associated with it. V2 functionally determines V1. Extend to sets of parts 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Normalization Key A key for a class C is collection of parts that (1) functionally determines all parts of C, and (2) no proper subset has this property. The concept of the key of a class is not a property of the class definition, but rather about the intended use of the class. 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Normalization A class is normalized if, whenever a part is functionally dependent on a set S of parts, S contains a key (an adaptation of Boyce -Codd normal form to classes). 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Example Source of problems: project number determines completion date, but project number is not part of key. Employee = <employeeNumber> Integer //key <employeeName> String <salary> Integer <projectNumber> Integer <completionDate> String. Three Problems: Before employees are recruited for a project, the completion date can be stored only in a strange way. If all employees leave project, completion date info. lost. If completion date of a project is changed, have to search through all instances of class Employee. 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Example/Solution Employee = <employeeNumber> Integer //key <employeeName> String <salary> Integer <projectNumber> Integer Project = <projectNumber> Integer //key <completionDate> String. Three Problems solved: Before employees are recruited for a project, the completion date can be stored only in a strange way. If all employees leave project, completion date info. lost. If completion date of a project is changed, have to search through all instances of class Employee. 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Persistence Which parts of an object need to be saved in the OO data base? Define a visitor: DBCopyVisitor (analogous to CopyVisitor). Define a strategy which says which parts need to be saved to the data base. o.t(DBCopyVisitor); 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Query Languages Problem: Users need to know too much about the data base schema (= UML class diagram) when they write queries. Solution: Use strategies with some extensions to write queries. from a:A via b:B to C at the C-object a and b are available. 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Commercial aspects Many companies selling OODBs, e.g. Object Design in Burlington, MA. OQL: a standard query language AQL: an adaptive version of OQL (not implemented) 9/22/2018 AOO / UML / OCL/Strategies

AOO / UML / OCL/Strategies Case study Learning cd from examples. 9/22/2018 AOO / UML / OCL/Strategies