Feature-Oriented Programming with Object Algebras

  • Bruno C. d. S. Oliveira
  • Tijs van der Storm
  • Alex Loh
  • William R. Cook
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7920)

Abstract

Object algebras are a new programming technique that enables a simple solution to basic extensibility and modularity issues in programming languages. While object algebras excel at defining modular features, the composition mechanisms for object algebras (and features) are still cumbersome and limited in expressiveness. In this paper we leverage two well-studied type system features, intersection types and type-constructor polymorphism, to provide object algebras with expressive and practical composition mechanisms. Intersection types are used for defining expressive run-time composition operators (combinators) that produce objects with multiple (feature) interfaces. Type-constructor polymorphism enables generic interfaces for the various object algebra combinators. Such generic interfaces can be used as a type-safe front end for a generic implementation of the combinators based on reflection. Additionally, we also provide a modular mechanism to allow different forms of self-references in the presence of delegation-based combinators. The result is an expressive, type-safe, dynamic, delegation-based composition technique for object algebras, implemented in Scala, which effectively enables a form of Feature-Oriented Programming using object algebras.

Keywords

Intersection Type Software Product Line Generic Interface Type Constructor Composition Mechanism 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Apel, S., Kästner, C., Grösslinger, A., Lengauer, C.: Type safety for feature-oriented product lines. Automated Software Engg. 17(3) (September 2010)Google Scholar
  2. 2.
    Apel, S., Kastner, C., Lengauer, C.: Featurehouse: Language-independent, automated software composition. In: ICSE 2009 (2009)Google Scholar
  3. 3.
    Apel, S., Leich, T., Rosenmüller, M., Saake, G.: Featurec++: On the symbiosis of feature-oriented and aspect-oriented programming. In: Glück, R., Lowry, M. (eds.) GPCE 2005. LNCS, vol. 3676, pp. 125–140. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  4. 4.
    Apel, S., Leich, T., Saake, G.: Aspectual mixin layers: aspects and features in concert. In: ICSE 2006 (2006)Google Scholar
  5. 5.
    Apel, S., Kästner, C.: An overview of feature-oriented software development. Journal of Object Technology 8(5), 49–84 (2009)CrossRefGoogle Scholar
  6. 6.
    Batory, D., Sarvela, J., Rauschmayer, A.: Scaling step-wise refinement. IEEE Trans. on Softw. Eng. 30(6), 355–371 (2004)CrossRefGoogle Scholar
  7. 7.
    Böhm, C., Berarducci, A.: Automatic synthesis of typed lambda-programs on term algebras. Theor. Comput. Sci., 135–154 (1985)Google Scholar
  8. 8.
    Bracha, G., Ungar, D.: Mirrors: design principles for meta-level facilities of object-oriented programming languages. In: OOPSLA 2004 (2004)Google Scholar
  9. 9.
    Bruce, K.B., Odersky, M., Wadler, P.: A statically safe alternative to virtual types. In: Jul, E. (ed.) ECOOP 1998. LNCS, vol. 1445, pp. 523–549. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  10. 10.
    Carette, J., Kiselyov, O., Shan, C.C.: Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages. J. Funct. Program. 19, 509–543 (2009)MathSciNetMATHCrossRefGoogle Scholar
  11. 11.
    Clifton, C., Leavens, G.T., Chambers, C., Millstein, T.: MultiJava: modular open classes and symmetric multiple dispatch for java. In: OOPSLA 2000 (2000)Google Scholar
  12. 12.
    Compagnoni, A.B., Pierce, B.C.: Higher-order intersection types and multiple inheritance. Math. Structures Comput. Sci. 6(5), 469–501 (1996)MathSciNetMATHGoogle Scholar
  13. 13.
    Cook, W.R., Palsberg, J.: A denotational semantics of inheritance and its correctness. In: OOPSLA 1989 (1989)Google Scholar
  14. 14.
    Cook, W.R.: Object-oriented programming versus abstract data types. In: de Bakker, J.W., Rozenberg, G., de Roever, W.-P. (eds.) REX 1990. LNCS, vol. 489, pp. 151–178. Springer, Heidelberg (1991)CrossRefGoogle Scholar
  15. 15.
    Coppo, M., Dezani-Ciancaglini, M.: A new type-assignment for λ-terms. Archiv. Math. Logik 19, 139–156 (1978)MathSciNetMATHCrossRefGoogle Scholar
  16. 16.
    Damiani, F., Padovani, L., Schaefer, I.: A formal foundation for dynamic delta-oriented software product lines. In: GPCE 2012 (2012)Google Scholar
  17. 17.
    Ernst, E.: Family polymorphism. In: Lindskov Knudsen, J. (ed.) ECOOP 2001. LNCS, vol. 2072, pp. 303–326. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  18. 18.
    Ernst, E.: Safe dynamic multiple inheritance. Nordic J. of Computing 9(3) (2002)Google Scholar
  19. 19.
    Ernst, E., Ostermann, K., Cook, W.R.: A virtual class calculus. In: POPL 2006 (2006)Google Scholar
  20. 20.
    Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns: Elements of Reusable Object-Oriented Software. Addisson-Wesley professional computing series. Addisson-Wesley (1994)Google Scholar
  21. 21.
    van Gurp, J., Bosch, J., Svahnberg, M.: On the notion of variability in software product lines. In: Proceedings of the Working IEEE/IFIP Conference on Software Architecture (WICSA 2001). IEEE Computer Society (2001)Google Scholar
  22. 22.
    Guttag, J.V., Horning, J.J.: The algebraic specification of abstract data types. Acta Informatica (1978)Google Scholar
  23. 23.
    Harrison, W., Ossher, H.: Subject-oriented programming (A critique of pure objects). In: OOPSLA 1993 (1993)Google Scholar
  24. 24.
    Hinze, R.: Generics for the masses. Journal of Functional Programming 16(4-5), 451–483 (2006)MathSciNetMATHCrossRefGoogle Scholar
  25. 25.
    Hofer, C., Ostermann, K., Rendel, T., Moors, A.: Polymorphic embedding of DSLs. In: GPCE 2008 (2008)Google Scholar
  26. 26.
    Jones, P., Wollrath, A., Scheifler, R., et al.: Method and system for dynamic proxy classes, US Patent 6,877,163 (2005)Google Scholar
  27. 27.
    Kiczales, G., Lamping, J., Mendhekar, A., Maeda, C., Lopes, C., Loingtier, J., Irwin, J.: Aspect-oriented programming. In: Akşit, M., Matsuoka, S. (eds.) ECOOP 1997. LNCS, vol. 1241, pp. 220–242. Springer, Heidelberg (1997)CrossRefGoogle Scholar
  28. 28.
    Lopez-Herrejon, R.E., Batory, D., Cook, W.: Evaluating support for features in advanced modularization technologies. In: Gao, X.-X. (ed.) ECOOP 2005. LNCS, vol. 3586, pp. 169–194. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  29. 29.
    McBride, C., Paterson, R.: Applicative programming with effects. Journal of Functional Programming 18(1), 1–13 (2008)MATHCrossRefGoogle Scholar
  30. 30.
    McDirmid, S., Flatt, M., Hsieh, W.C.: Jiazzi: new-age components for old-fashioned java. In: OOPSLA 2001 (2001)Google Scholar
  31. 31.
    Moors, A., Piessens, F., Odersky, M.: Generics of a higher kind. In: OOPSLA 2008 (2008)Google Scholar
  32. 32.
    Nystrom, N., Qi, X., Myers, A.C.: J&: nested intersection for scalable software composition. In: OOPSLA 2006 (2006)Google Scholar
  33. 33.
    Odersky, M.: The Scala Language Specification, Version 2.9. EPFL (2011), http://www.scala-lang.org/docu/files/ScalaReference.pdf
  34. 34.
    Odersky, M., Zenger, M.: Scalable component abstractions. In: OOPSLA 2005 (2005)Google Scholar
  35. 35.
    Oliveira, B.C.d.S., Schrijvers, T., Cook, W.R.: Mri: Modular reasoning about interference in incremental programming. Journal of Functional Programming 22, 797–852 (2012)MathSciNetCrossRefGoogle Scholar
  36. 36.
    Oliveira, B.C.d.S.: Modular visitor components. In: Drossopoulou, S. (ed.) ECOOP 2009. LNCS, vol. 5653, pp. 269–293. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  37. 37.
    Oliveira, B.C.d.S., Cook, W.R.: Extensibility for the masses: Practical extensibility with object algebras. In: Noble, J. (ed.) ECOOP 2012. LNCS, vol. 7313, pp. 2–27. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  38. 38.
    Oliveira, B.C.d.S., Gibbons, J.: Typecase: a design pattern for type-indexed functions. In: Haskell 2005 (2005)Google Scholar
  39. 39.
    Oliveira, B.C.d.S., Hinze, R., Löh, A.: Extensible and modular generics for the masses. In: Trends in Functional Programming (2006)Google Scholar
  40. 40.
    Oliveira, B.C.d.S., Moors, A., Odersky, M.: Type classes as objects and implicits. In: OOPSLA 2010 (2010)Google Scholar
  41. 41.
    Oliveira, B.C.d.S., Wang, M., Gibbons, J.: The visitor pattern as a reusable, generic, type-safe component. In: OOPSLA 2008 (2008)Google Scholar
  42. 42.
    Ostermann, K.: Dynamically composable collaborations with delegation layers. In: Magnusson, B. (ed.) ECOOP 2002. LNCS, vol. 2374, pp. 89–110. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  43. 43.
    Prehofer, C.: Feature-oriented programming: A fresh look at objects. In: Akşit, M., Matsuoka, S. (eds.) ECOOP 1997. LNCS, vol. 1241, pp. 419–443. Springer, Heidelberg (1997)CrossRefGoogle Scholar
  44. 44.
    Reynolds, J.C.: User-defined types and procedural data structures as complementary approaches to type abstraction. In: Schuman, S.A. (ed.) New Directions in Algorithmic Languages, pp. 157–168 (1975)Google Scholar
  45. 45.
    Reynolds, J.C.: Towards a theory of type structure. In: Robinet, B. (ed.) Programming Symposium. LNCS, vol. 19, pp. 408–425. Springer, Heidelberg (1974)CrossRefGoogle Scholar
  46. 46.
    Schaefer, I., Bettini, L., Damiani, F.: Compositional type-checking for delta-oriented programming. In: AOSD 2011 (2011)Google Scholar
  47. 47.
    Smaragdakis, Y., Batory, D.: Implementing layered designs with mixin layers. In: Jul, E. (ed.) ECOOP 1998. LNCS, vol. 1445, pp. 550–570. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  48. 48.
    Tarr, P., Ossher, H., Harrison, W., Sutton Jr., S.M.: N degrees of separation: multi-dimensional separation of concerns. In: ICSE 1999 (1999)Google Scholar
  49. 49.
    Thaker, S., Batory, D., Kitchin, D., Cook, W.: Safe composition of product lines. In: GPCE 2007 (2007)Google Scholar
  50. 50.
    Torgersen, M.: The expression problem revisited – four new solutions using generics. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 123–146. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  51. 51.
    Wadler, P.: The Expression Problem. Email, discussion on the Java Genericity mailing list (November 1998)Google Scholar
  52. 52.
    Wehr, S., Thiemann, P.: JavaGI: The interaction of type classes with interfaces and inheritance. ACM Trans. Program. Lang. Syst. 33 (July 2011)Google Scholar
  53. 53.
    Zenger, M., Odersky, M.: Extensible algebraic datatypes with defaults. In: ICFP 2001 (2001)Google Scholar
  54. 54.
    Zenger, M., Odersky, M.: Independently extensible solutions to the expression problem. In: FOOL 2005 (2005)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2013

Authors and Affiliations

  • Bruno C. d. S. Oliveira
    • 1
  • Tijs van der Storm
    • 2
  • Alex Loh
    • 3
  • William R. Cook
    • 3
  1. 1.National University of SingaporeSingapore
  2. 2.Centrum Wiskunde & Informatica (CWI)The Netherlands
  3. 3.University of TexasAustinUSA

Personalised recommendations