Skip to main content

Extending OCL with Map and Function Types

  • Conference paper
  • First Online:
Fundamentals of Software Engineering (FSEN 2021)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 12818))

Included in the following conference series:

Abstract

Map and function types are of high utility in software specification and design, for example, maps can be used to represent configurations or caches, whilst function values can be used to enable genericity and reuse in a specification, and to support mechanisms such as callbacks or closures in an implementation. Map and function types have been incorporated into the leading programming languages, including Java, C++, Swift and Python.

The Object Constraint Language (OCL) specification notation lacks such types, and in this paper we make a proposal for a consistent extension of OCL with map and function types, and we identify modifications to OCL semantics to include these types. We also describe how map and function types are implemented using the Eclipse AgileUML toolset.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 59.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 79.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Used in the ATL extension of OCL.

References

  1. AgileUML repository (2020). https://github.com/eclipse/agileuml/

  2. Belaunde, M.: Evolution of the OCL OMG specification, OCL (2010)

    Google Scholar 

  3. Sánchez Cuadrado, J., Jouault, F., García Molina, J., Bézivin, J.: Optimization patterns for OCL-based model transformations. In: Chaudron, M.R.V. (ed.) MODELS 2008. LNCS, vol. 5421, pp. 273–284. Springer, Heidelberg (2009). https://doi.org/10.1007/978-3-642-01648-6_29

    Chapter  Google Scholar 

  4. Ciesielski, K.: Set Theory for the Working Mathematician. Cambridge University Press, Cambridge (1997)

    Book  Google Scholar 

  5. Cook, S., Kleppe, A., Mitchell, R., Rumpe, B., Warmer, J., Wills, A.: The Amsterdam manifesto on OCL. In: Clark, T., Warmer, J. (eds.) Object Modeling with the OCL. LNCS, vol. 2263, pp. 115–149. Springer, Heidelberg (2002). https://doi.org/10.1007/3-540-45669-4_7

    Chapter  MATH  Google Scholar 

  6. Eclipse, ATL user guide, eclipse.org (2019)

    Google Scholar 

  7. Eclipse AgileUML project (2020). https://projects.eclipse.org/projects/modeling.agileuml

  8. Eclipse OCL Version 6.4.0 (2021). https://projects.eclipse.org/projects/modeling.mdt.ocl

  9. The Epsilon Object Language (2020). https://www.eclipse.org/epsilon/doc/eol

  10. Hennicker, R., Hussmann, H., Bidoit, M.: On the precise meaning of OCL constraints. In: Clark, T., Warmer, J. (eds.) Object Modeling with the OCL. LNCS, vol. 2263, pp. 69–84. Springer, Heidelberg (2002). https://doi.org/10.1007/3-540-45669-4_5

    Chapter  MATH  Google Scholar 

  11. Kleppe, A., Warmer, J., Cook, S.: Informal formality? The object constraint language and its application in the UML metamodel. In: Bézivin, J., Muller, P.-A. (eds.) UML 1998. LNCS, vol. 1618, pp. 148–161. Springer, Heidelberg (1999). https://doi.org/10.1007/978-3-540-48480-6_12

    Chapter  Google Scholar 

  12. Kleppe, A.: Object constraint language: metamodelling semantics (Chap. 7). In: UML 2 Semantics and Applications. Wiley (2009)

    Google Scholar 

  13. Lano, K.: The B Language and Method. Springer, Heidelberg (1996). https://doi.org/10.1007/978-1-4471-1494-9

    Book  Google Scholar 

  14. Lano, K.: A compositional semantics of UML-RSDS. Softw. Syst. Model. 8(1), 85–116 (2009). https://doi.org/10.1007/s10270-007-0064-x

    Article  Google Scholar 

  15. Lano, K., Clark, T., Kolahdouz-Rahimi, S.: A framework for model transformation verification. Form. Asp. Comput. 27(1), 193–235 (2014). https://doi.org/10.1007/s00165-014-0313-z

    Article  MathSciNet  MATH  Google Scholar 

  16. Lano, K.: Agile Model-Based Development Using UML-RSDS. CRC Press, Boca Raton (2016)

    Google Scholar 

  17. Lano, K.: Map type support in OCL?, November 2018. https://www.eclipse.org/forums/index.php/t/1096077/

  18. OMG, Object Constraint Language 2.4 Specification (2014)

    Google Scholar 

  19. OMG, MOF2 Query/View/Transformation v1.3 (2016)

    Google Scholar 

  20. OMG (2020). https://issues.omg.org/issues/spec/OCL/2.4

  21. Richters, M., Gogolla, M.: On formalizing the UML object constraint language OCL. In: Ling, T.-W., Ram, S., Li Lee, M. (eds.) ER 1998. LNCS, vol. 1507, pp. 449–464. Springer, Heidelberg (1998). https://doi.org/10.1007/978-3-540-49524-6_35

    Chapter  Google Scholar 

  22. Spivey, J.: The Z Notation. Prentice Hall, Hoboken (1989)

    MATH  Google Scholar 

  23. Willink, E.: OCL omissions and contradictions, OMG ADTF (2012)

    Google Scholar 

  24. Willink, E.: Reflections on OCL 2. J. Object Technol. 19(3), 1–16 (2020)

    Google Scholar 

  25. Willink, E.: An OCL map type. In: OCL 2019 (2019)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Kevin Lano .

Editor information

Editors and Affiliations

A Additional Map Type Operators

A Additional Map Type Operators

The following map operators can also be formalised in our proposed extension of OCL.

size() : Integer

figure k

This is equal to \(self{\rightarrow }keys(){\rightarrow }size()\).

includesValue(object : T) : Boolean True if the object is an element of the map range, false otherwise:

figure l

Similarly for \({\rightarrow }includesKey()\), \({\rightarrow }excludesValue()\), \({\rightarrow }excludesKey()\).

count(object : T) : Integer The number of times the object occurs as an element of the map range (a bag):

figure m

includesAll(c2 : Map(K,T)) : Boolean True if c2 is a map, and the set of pairs of self contains all those of c2, false otherwise:

figure n

Similarly for \({\rightarrow }excludesAll()\).

isEmpty() : Boolean, notEmpty() : Boolean Defined based on \(self{\rightarrow }asSet()\).

max() : T, min() : T, sum() : T Defined as the corresponding operations on \(self{\rightarrow }values()\).

asSet() : Set(Tuple(key : K, value : T)) The set of pairs of elements in the map. Since duplicate keys are not permitted, this has the same size as \(self{\rightarrow }keys()\).

restrict(ks : Set(K)) : Map(K,T) Domain restriction . The map restricted to the keys in ks. Its elements are the pairs of self whose key is in ks:

figure o

Range restriction is provided via the \({\rightarrow }select\) operator.

-(m: Map(K,T)) : Map(K,T) Map subtraction: the elements of self that are not in m.

figure p

union(m : Map(K,T)) : Map(K,T) Map override, the operation \(self \oplus m\) or \(self~{{<}{+}}~m\) in mathematical notation. This consists of the pairs of self which do not conflict with pairs of m, together with all pairs of m:

figure q

This is the same as putAll in EOL [9]. Unlike set union, it is not commutative.

intersection(m : Map(K,T)) : Map(K,T) The pairs of self which are also in m:

figure r

This is associative and commutative.

including(k : K, v : T) : Map(K,T) The pairs of self, with the additional/overriding mapping of k to v:

figure s

We also use the abbreviated notation \(m[k] = v\) for \(m = m{\text{@ }pre}{\rightarrow }including(k,v)\).

excluding(k : K, v : T) : Map(K,T) The pairs of self, with any mapping of k to v removed:

figure t

any Defined as

figure u

Likewise for forAll, exists, one.

select The map formed by restricting to range elements which satisfy the select condition:

figure v

Similarly for reject.

Rights and permissions

Reprints and permissions

Copyright information

© 2021 IFIP International Federation for Information Processing

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Lano, K., Kolahdouz-Rahimi, S. (2021). Extending OCL with Map and Function Types. In: Hojjat, H., Massink, M. (eds) Fundamentals of Software Engineering. FSEN 2021. Lecture Notes in Computer Science(), vol 12818. Springer, Cham. https://doi.org/10.1007/978-3-030-89247-0_8

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-89247-0_8

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-89246-3

  • Online ISBN: 978-3-030-89247-0

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics