Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Object Constraint Language

From Wikipedia, the free encyclopedia
Declarative language
This article needs to beupdated. Please help update this article to reflect recent events or newly available information.(April 2018)

TheObject Constraint Language (OCL) is adeclarative language describing rules applying toUnified Modeling Language (UML) models developed atIBM and is now part of the UML standard. Initially, OCL was merely a formal specification language extension for UML.[1] OCL may now be used with anyMeta-Object Facility (MOF)Object Management Group (OMG)meta-model, including UML.[2] The Object Constraint Language is a precise text language that provides constraint and object query expressions on any MOF model or meta-model that cannot otherwise be expressed by diagrammatic notation. OCL is a key component of the new OMG standard recommendation for transforming models, the Queries/Views/Transformations (QVT) specification.

Description

[edit]

OCL is a descendant ofSyntropy, a second-generation object-oriented analysis and design method. The OCL 1.4 definition specified a constraint language. In OCL 2.0, the definition has been extended to include general object query language definitions.[3]

OCL statements are constructed in four parts:

  1. a context that defines the limited situation in which the statement is valid
  2. a property that represents some characteristics of the context (e.g., if the context is a class, a property might be an attribute)
  3. an operation (e.g., arithmetic, set-oriented) that manipulates or qualifies a property, and
  4. keywords (e.g., if, then, else, and, or, not, implies) that are used to specify conditional expressions.

Relation

[edit]

OCL and UML

[edit]

OCL supplements UML by providing expressions that have neither the ambiguities of natural language nor the inherent difficulty of using complex mathematics.[3] OCL is also a navigation language for graph-based models.

OCL and MOF

[edit]

OCL makes aMeta-Object Facility model more precise by associating assertions with its meta-elements.

OCL and QVT

[edit]

Of particular importance toModel Driven Engineering (MDE) ormodel-driven architecture is the notion ofModel transformation. TheOMG has defined a specific standard for model transformation calledMOF/QVT or in shortQVT. Several model transformation languages likeGReAT,VIATRA, orTefkat are presently available, with different levels of compliance with the QVT standard. Many of these languages are built on top of OCL, which is the main part of theQVT-compliance.

Alternatives

[edit]

Being a rule-based validation language,Schematron may be considered an alternative to OCL. However Schematron works for Extensible Markup Language(XML) trees while OCL makes it possible to navigateMOF-based models and meta-models (i.e. XML Metadata Interchange (XMI) trees). In other words, OCL relates to UML or MOF similarly to how Schematron relates toXML. (Note that Schematron usesXPath to navigate inside the XML trees.)
Being a model specification language permitting designers to decorate a model or a meta-model with side-effect-free annotations, OCL could be replaced by languages likeAlloy. Automated OCL generation is in principle possible from natural language.[4]

Examples
ConstraintOCL Equivalent
The age of a person is not negative.context Personinv: self.age >=0
A person is younger than its parents.context Personinv: self.parents->forAll(p|p.age>self.age)
After a birthday, a person becomes one year older.context Person::hasBirthday()post: self.age=self.age@pre+1
A Person has 2 parents at max.context Personinv: self.parents->size()<=2
After somebody has a child, his/her child-set is not empty, and it is larger than before.context Person::getsChild()post: self.childs->notEmpty() and self.childs->size() > self.childs@pre->size()
Only an adult can be owner of a car.context Personinv: self.age<18implies self.cars->isEmpty()
The first registration of a car can not be before it is built.context Autoinv: self.registration>=self.constructionYear
Every Person that has a car has at least one car which is younger than the Person.context Personinv: self.cars->notEmpty()implies self.cars->exists( c |Calendar.YEAR - c.constructionYear < self.age)
Nobody can be his/her own parent.context Personinv: self.parents->excludes(self)
There's at least one Person which owns a car.context Personinv: Person.allInstances()->exists(p | p.cars->size() > 0)


Extensions

[edit]

Eclipse OCL[5] extends Standard OCL with additional operators and a type for Maps. AgileUML extends Standard OCL with Map and Function types.[6] These extensions are consistent with the map and function types present in modern programming languages such as Python and Swift.

See also

[edit]

References

[edit]
  1. ^Object Management Group (OMG);Object Constraint Language Specification, Chapter 7 ofOMG Unified Modeling Language Specification, Version 1.3, March 2000 (first edition)
  2. ^Object Management Group (OMG);Object Constraint Language OMG Available Specification Version 2.0, May 2006
  3. ^abThis article is based on material taken fromObject+Constraint+Language at theFree On-line Dictionary of Computing prior to 1 November 2008 and incorporated under the "relicensing" terms of theGFDL, version 1.3 or later.
  4. ^Imran Sarwar Bajwa (October 2010). "OCL Constraints Generation from Natural Language Specification, 2010".IEEE.doi:10.1109/EDOC.2010.33.S2CID 7495256.{{cite journal}}:Cite journal requires|journal= (help)
  5. ^"Eclipse OCL™ (Object Constraint Language)". 31 January 2013.
  6. ^Lano, Kevin; Kolahdouz-Rahimi, Shekoufeh (2021)."Extending OCL with Map and Function Types".Fundamentals of Software Engineering. Lecture Notes in Computer Science. Vol. 12818. pp. 108–123.doi:10.1007/978-3-030-89247-0_8.ISBN 978-3-030-89246-3.S2CID 239029860.

External links

[edit]
In current use
Proprietary
Superseded
1–9999
10000–19999
20000–29999
30000+
Retrieved from "https://en.wikipedia.org/w/index.php?title=Object_Constraint_Language&oldid=1282302712"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp