SCALA ROLES - A Lightweight Approach towards Reusable Collaborations

Michael Pradel, Martin Odersky



Purely class-based implementations of object-oriented software are often inappropriate for reuse. In contrast, the notion of objects playing roles in a collaboration has been proven to be a valuable reuse abstraction. However, existing solutions to enable role-based programming tend to require vast extensions of the underlying programming language, and thus, are difficult to use in every day work. We present a programming technique, based on dynamic proxies, that allows to augment an object’s type at runtime while preserving strong static type safety. It enables role-based implementations that lead to more reuse and better separation of concerns.


  1. Bäumer, D., Riehle, D., Siberski, W., and Wulf, M. (1997). The Role Object pattern. In Proceedings of the Conference on Pattern Languages of Programs (PLoP 7897).
  2. Gamma, E., Helm, R., Johnson, R., and Vlissides, J. (1995). Design patterns: elements of reusable object-oriented software. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA.
  3. Guarino, N. (1992). Concepts, attributes and arbitrary relations: some linguistic and ontological criteria for structuring knowledge bases. Data Knowl. Eng., 8(3):249-261.
  4. Hannemann, J. and Kiczales, G. (2002). Design pattern implementation in Java and AspectJ. SIGPLAN Not., 37(11):161-173.
  5. Harrison, W. (1997). Homepage on subjectoriented programming and design patterns.
  6. Herrmann, S. (2007). A precise model for contextual roles: The programming language ObjectTeams/Java. Applied Ontology, 2(2):181-207.
  7. Herrmann, S., Hundt, C., and Mehner, K. (2004). Translation polymorphism in Object Teams. Technical report, TU Berlin.
  8. Kendall, E. A. (1999). Role model designs and implementations with aspect-oriented programming. SIGPLAN Not., 34(10):353-369.
  9. Kiczales, G., Lamping, J., Mendhekar, A., Maeda, C., Lopes, C. V., Loingtier, J.-M., and Irwin, J. (1997). Aspect-oriented programming. In Proceedings of the European Conference on Object-Oriented Programming (ECOOP 1997), pages 220-242.
  10. Kristensen, B. B. and Osterbye, K. (1996). Roles: conceptual abstraction theory and practical language issues. Theor. Pract. Object Syst., 2(3):143-160.
  11. Object Management Group OMG (2007). OMG Unified Modeling Language (OMG UML), superstructure, v2.1.2.
  12. Odersky, M. (2008). Scala Language Specification. Version 2.7,
  13. Odersky, M., Spoon, L., and Venners, B. (2008). Programming in Scala, A comprehensive step-by-step guide. Artima.
  14. Reenskaug, T., Wold, P., and Lehne, O. A. (1996). Working with Objects, The OOram Software Engineering Method. Manning Publications Co.
  15. Riehle, D. (1997). Composite design patterns. In OOPSLA 7897: Proceedings of the 12th ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications, pages 218-228, New York, NY, USA. ACM Press.
  16. Riehle, D. (2000). Framework Design: A Role Modeling Approach. PhD thesis, ETH Z ürich.
  17. Smaragdakis, Y. and Batory, D. (2002). Mixin layers: an object-oriented implementation technique for refinements and collaboration-based designs. ACM Transactions on Software Engineering and Methodology (TOSEM), 11(2):215-255.
  18. Steimann, F. (2000). On the representation of roles in object-oriented and conceptual modelling. Data Knowledge Engineering, 35(1):83-106.

Paper Citation

in Harvard Style

Pradel M. and Odersky M. (2008). SCALA ROLES - A Lightweight Approach towards Reusable Collaborations . In Proceedings of the Third International Conference on Software and Data Technologies - Volume 1: ICSOFT, ISBN 978-989-8111-51-7, pages 13-20. DOI: 10.5220/0001873700130020

in Bibtex Style

author={Michael Pradel and Martin Odersky},
title={SCALA ROLES - A Lightweight Approach towards Reusable Collaborations},
booktitle={Proceedings of the Third International Conference on Software and Data Technologies - Volume 1: ICSOFT,},

in EndNote Style

JO - Proceedings of the Third International Conference on Software and Data Technologies - Volume 1: ICSOFT,
TI - SCALA ROLES - A Lightweight Approach towards Reusable Collaborations
SN - 978-989-8111-51-7
AU - Pradel M.
AU - Odersky M.
PY - 2008
SP - 13
EP - 20
DO - 10.5220/0001873700130020