Traits

ACM Transactions on Programming Languages and Systems - Tập 28 Số 2 - Trang 331-388 - 2006
Sté́phane Ducasse1, Oscar Nierstrasz2, Nathanael Schärli3, Roel Wuyts4, Andrew P. Black5
1University of Berne and LISTIC, University of Savoie, Annecy Cedex, France#TAB#
2University of Berne, Berne, Switzerland
3University of Berne, Zürich, Switzerland
4Université libre de bruxelles, Belgium
5Portland State University, Portland, Oregon

Tóm tắt

Inheritance is well-known and accepted as a mechanism for reuse in object-oriented languages. Unfortunately, due to the coarse granularity of inheritance, it may be difficult to decompose an application into an optimal class hierarchy that maximizes software reuse. Existing schemes based on single inheritance, multiple inheritance, or mixins, all pose numerous problems for reuse. To overcome these problems we propose traits , pure units of reuse consisting only of methods. We develop a formal model of traits that establishes how traits can be composed, either to form other traits, or to form classes. We also outline an experimental validation in which we apply traits to refactor a nontrivial application into composable units.

Từ khóa


Tài liệu tham khảo

10.1145/97945.97966

Ancona , D. , Lagorio , G. , and Zucca , E . 2000. Jam---a smooth extension of Java with mixins . In ECOOP 2000 . Number 1850 in Lecture Notes in Computer Science. 145--178.]] Ancona, D., Lagorio, G., and Zucca, E. 2000. Jam---a smooth extension of Java with mixins. In ECOOP 2000. Number 1850 in Lecture Notes in Computer Science. 145--178.]]

Bak , L. , Grarup , G. B. S. , Griesemer , R. , Griswold , D. , and Hölzle , U . 2002 . Mixins in Strongtalk. In ECOOP '02 Workshop on Inheritance.]] Bak, L., Grarup, G. B. S., Griesemer, R., Griswold, D., and Hölzle, U. 2002. Mixins in Strongtalk. In ECOOP '02 Workshop on Inheritance.]]

10.1145/236337.236343

10.1145/136586.136587

Batory , D. , Sarvela , J. N. , and Rauschmayer , A . 2003. Scaling step-wise refinement . In Proceedings of the 25th International Conference on Software Engineering. IEEE Computer Society, 187--197 .]] Batory, D., Sarvela, J. N., and Rauschmayer, A. 2003. Scaling step-wise refinement. In Proceedings of the 25th International Conference on Software Engineering. IEEE Computer Society, 187--197.]]

Black , A. P. and Schärli , N . 2004. Traits: Tools and methodology . In Proceedings ICSE 2004 . 676--686.]] Black, A. P. and Schärli, N. 2004. Traits: Tools and methodology. In Proceedings ICSE 2004. 676--686.]]

10.1145/949305.949311

Bobrow , D. G. and Goldstein , I. P . 1980. Representing design alternatives . In Proceedings of the Conference on Artificial Intelligence and the Simulation of Behavior.]] Bobrow, D. G. and Goldstein, I. P. 1980. Representing design alternatives. In Proceedings of the Conference on Artificial Intelligence and the Simulation of Behavior.]]

10.1207/s15516709cog0101_2

10.1145/357146.357147

Bouraqadi , N. 2004 . Safe metaclass composition using mixin-based inheritance . J. Comput. Lang. Syst. Struct. 30 , 1 -- 2 (Apr.), 49--61.]] Bouraqadi, N. 2004. Safe metaclass composition using mixin-based inheritance. J. Comput. Lang. Syst. Struct. 30, 1--2 (Apr.), 49--61.]]

10.1145/286936.286949

10.1145/97945.97982

10.1145/165854.165893

10.5555/230849.230854

10.1145/190679.190683

Cannon , H. I. 1982 . Flavors: A non-hierarchical approach to object-oriented programming. Tech. rep. , Symbolics Inc .]] Cannon, H. I. 1982. Flavors: A non-hierarchical approach to object-oriented programming. Tech. rep., Symbolics Inc.]]

10.1145/203095.203096

10.1145/38765.38822

Cook , S. 1987 . OOPSLA '87 Panel P2: Varieties of inheritance. In OOPSLA '87 Addendum To The Proceedings. ACM Press, 35--40 .]] Cook, S. 1987. OOPSLA '87 Panel P2: Varieties of inheritance. In OOPSLA '87 Addendum To The Proceedings. ACM Press, 35--40.]]

10.1145/96709.96721

10.1145/74877.74922

10.1145/141936.141938

10.1145/966873.806468

Danforth , S. and Forman , I. R . 1994. Derived metaclass in SOM . In Proceedings of TOOLS EUROPE '94 . 63--73.]] Danforth, S. and Forman, I. R. 1994. Derived metaclass in SOM. In Proceedings of TOOLS EUROPE '94. 63--73.]]

10.1145/74877.74900

10.1016/j.cl.2004.11.003

10.1145/141936.141939

10.1145/504282.504299

10.1145/190679.190682

10.1145/268946.268961

Forman , I. R. and Danforth , S . 1999 . Putting Metaclasses to Work: A New Dimension in Object-Oriented Programming . Addison-Wesley .]] Forman, I. R. and Danforth, S. 1999. Putting Metaclasses to Work: A New Dimension in Object-Oriented Programming. Addison-Wesley.]]

Goldberg A. and Robson D. 1983. Smalltalk 80: the Language and its Implementation. Addison Wesley Reading Mass.]] Goldberg A. and Robson D. 1983. Smalltalk 80: the Language and its Implementation. Addison Wesley Reading Mass.]]

Goldstein , I. P. and Bobrow , D. G . 1980a. Descriptions for a programming environment . In Proceedings of the First Annual Conference of the National Association for Artificial Intelligence.]] Goldstein, I. P. and Bobrow, D. G. 1980a. Descriptions for a programming environment. In Proceedings of the First Annual Conference of the National Association for Artificial Intelligence.]]

10.1145/800087.802792

Goldstein , I. P. and Roberts , R. B . 1977. Nudge, a knowledge-based scheduling program . In Proceedings of the Fifth International Joint Conference on Artifical Intelligence. 257--263 .]] Goldstein, I. P. and Roberts, R. B. 1977. Nudge, a knowledge-based scheduling program. In Proceedings of the Fifth International Joint Conference on Artifical Intelligence. 257--263.]]

10.1145/74877.74909

Guttag , J. V. , Horning , J. J. , and Wing , J. M. 1985 . The Larch family of specification languages . IEEE Trans. Softw. Eng. 2 , 5 (Sept.), 24--36.]] Guttag, J. V., Horning, J. J., and Wing, J. M. 1985. The Larch family of specification languages. IEEE Trans. Softw. Eng. 2, 5 (Sept.), 24--36.]]

10.1145/165854.165932

10.1145/355045.355048

10.1145/190679.190684

10.1145/512760.512762

10.1145/263698.263754

10.1002/spe.504

Keene , S. E. 1989. Object-Oriented Programming in Common-Lisp . Addison Wesley .]] Keene, S. E. 1989. Object-Oriented Programming in Common-Lisp. Addison Wesley.]]

Kiczales G. des Rivières J. and Bobrow D. G. 1991. The Art of the Metaobject Protocol. MIT Press.]] Kiczales G. des Rivières J. and Bobrow D. G. 1991. The Art of the Metaobject Protocol. MIT Press.]]

Kiczales , G. , Hilsdale , E. , Hugunin , J. , Kersten , M. , Palm , J. , and Griswold , W. G . 2001. An overview of AspectJ . In Proceedings of ECOOP 2001 . Number 2072 in LNCS. Springer Verlag, 327--353.]] Kiczales, G., Hilsdale, E., Hugunin, J., Kersten, M., Palm, J., and Griswold, W. G. 2001. An overview of AspectJ. In Proceedings of ECOOP 2001. Number 2072 in LNCS. Springer Verlag, 327--353.]]

Kiczales , G. , Lamping , J. , Mendhekar , A. , Maeda , C. , Lopes , C. , Loingtier , J.-M. , and Irwin , J . 1997 . Aspect-Oriented Programming. In Proceedings of ECOOP '97 , M. Aksit and S. Matsuoka, Eds. LNCS , vol. 1241 . Springer-Verlag, Jyvaskyla, Finland, 220--242.]] Kiczales, G., Lamping, J., Mendhekar, A., Maeda, C., Lopes, C., Loingtier, J.-M., and Irwin, J. 1997. Aspect-Oriented Programming. In Proceedings of ECOOP '97, M. Aksit and S. Matsuoka, Eds. LNCS, vol. 1241. Springer-Verlag, Jyvaskyla, Finland, 220--242.]]

10.5555/646156.679712

LaLonde , W. and Pugh , J. 1991 . Subclassing ≠ Subtyping ≠ Is-a . J. Object-Oriented Prog. 3 , 5 (Jan.), 57--62.]] LaLonde, W. and Pugh, J. 1991. Subclassing ≠ Subtyping ≠ Is-a. J. Object-Oriented Prog. 3, 5 (Jan.), 57--62.]]

10.1145/63264.63265

Ledoux , T. and Cointe , P . 1996. Explicit metaclasses as a tool for improving the design of class libraries . In Proceedings of ISOTAS '96 , LNCS 1049. JSSST-JAIST, 38--55.]] Ledoux, T. and Cointe, P. 1996. Explicit metaclasses as a tool for improving the design of class libraries. In Proceedings of ISOTAS '96, LNCS 1049. JSSST-JAIST, 38--55.]]

Lienhard , A. 2004. Bootstrapping Traits . M.S. thesis , University of Bern.]] Lienhard, A. 2004. Bootstrapping Traits. M.S. thesis, University of Bern.]]

10.1145/97945.97964

Mens , T. and van Limberghen , M. 1996 . Encapsulation and composition as orthogonal operators on mixins: A solution to multiple inheritance problems . Object Oriented Systems 3 , 1, 1 -- 30 .]] Mens, T. and van Limberghen, M. 1996. Encapsulation and composition as orthogonal operators on mixins: A solution to multiple inheritance problems. Object Oriented Systems 3, 1, 1--30.]]

Meyer , B. 1988. Object-oriented Software Construction . Prentice-Hall .]] Meyer, B. 1988. Object-oriented Software Construction. Prentice-Hall.]]

10.5555/129093

Meyer , B. 1997. Object-Oriented Software Construction , Second ed. Prentice-Hall .]] Meyer, B. 1997. Object-Oriented Software Construction, Second ed. Prentice-Hall.]]

10.1007/BFb0053380

10.1145/582419.582426

Mohnen , M. 2002 . Interfaces with default implementations in Java . In Conference on the Principles and Practice of Programming in Java. ACM Press , Dublin, Ireland, 35--40.]] Mohnen, M. 2002. Interfaces with default implementations in Java. In Conference on the Principles and Practice of Programming in Java. ACM Press, Dublin, Ireland, 35--40.]]

10.1145/28697.28698

Moura P. 2003. Logtalk. Ph.D. thesis Universidade da Beira Interior.]] Moura P. 2003. Logtalk. Ph.D. thesis Universidade da Beira Interior.]]

Musser D. R. and Saini A. 1996. STL Tutorial and Reference Guide. Addison Wesley.]] Musser D. R. and Saini A. 1996. STL Tutorial and Reference Guide. Addison Wesley.]]

Odersky , M. , Altherr , P. , Cremet , V. , Emir , B. , Maneth , S. , Micheloud , S. , Mihaylov , N. , Schinz , M. , Stenman , E. , and Zenger , M . 2004 . An overview of the Scala programming language. Tech. Rep. 64, école Polytechnique Fédérale de Lausanne, 1015 Lausanne, Switzerland.]] Odersky, M., Altherr, P., Cremet, V., Emir, B., Maneth, S., Micheloud, S., Mihaylov, N., Schinz, M., Stenman, E., and Zenger, M. 2004. An overview of the Scala programming language. Tech. Rep. 64, école Polytechnique Fédérale de Lausanne, 1015 Lausanne, Switzerland.]]

10.1145/190679.190681

Riel , A. J. 1996. Object-Oriented Design Heuristics . Addison Wesley .]] Riel, A. J. 1996. Object-Oriented Design Heuristics. Addison Wesley.]]

Sakkinen , M. 1989 . Disciplined inheritance . In Proceedings of ECOOP '89 , S. Cook, Ed. Cambridge University Press, Nottingham, 39--56.]] Sakkinen, M. 1989. Disciplined inheritance. In Proceedings of ECOOP '89, S. Cook, Ed. Cambridge University Press, Nottingham, 39--56.]]

Sakkinen , M. 1992 . The darker side of C++ revisited . Structured Programming 13 , 4, 155 -- 177 .]] Sakkinen, M. 1992. The darker side of C++ revisited. Structured Programming 13, 4, 155--177.]]

Schärli , N. and Black , A. P . 2003 . A browser for incremental programming. Tech. Rep. CSE-03-008, OGI School of Science & Engineering , Beaverton, Oregon, USA. Apr.]] Schärli, N. and Black, A. P. 2003. A browser for incremental programming. Tech. Rep. CSE-03-008, OGI School of Science & Engineering, Beaverton, Oregon, USA. Apr.]]

Schärli , N. , Ducasse , S. , Nierstrasz , O. , and Black , A . 2003. Traits: Composable units of behavior . In Proceedings of ECOOP 2003 (European Conference on Object-Oriented Programming). LNCS , vol. 2743 . Springer Verlag, 248--274.]] Schärli, N., Ducasse, S., Nierstrasz, O., and Black, A. 2003. Traits: Composable units of behavior. In Proceedings of ECOOP 2003 (European Conference on Object-Oriented Programming). LNCS, vol. 2743. Springer Verlag, 248--274.]]

Schärli , N. , Ducasse , S. , Nierstrasz , O. , and Wuyts , R . 2004. Composable encapsulation policies . In Proceedings of ECOOP 2004 (European Conference on Object-Oriented Programming). LNCS 3086 . Springer Verlag, 26--50.]] Schärli, N., Ducasse, S., Nierstrasz, O., and Wuyts, R. 2004. Composable encapsulation policies. In Proceedings of ECOOP 2004 (European Conference on Object-Oriented Programming). LNCS 3086. Springer Verlag, 26--50.]]

10.1145/190679.199221

10.5555/645547.658858

Smaragdakis , Y. and Batory , D . 1998. Implementing layered design with mixin layers . In Proceedings of ECOOP '98 , E. Jul, Ed. LNCS , vol. 1445 . Brussels, Belgium, 550--570.]] Smaragdakis, Y. and Batory, D. 1998. Implementing layered design with mixin layers. In Proceedings of ECOOP '98, E. Jul, Ed. LNCS, vol. 1445. Brussels, Belgium, 550--570.]]

Smaragdakis , Y. and Batory , D . 2000. Mixin-based programming in C++ . In 2nd Symposium on Generative and Component-Based Software Engineering (GCSE 2000 ). Erfurth, Germany.]] Smaragdakis, Y. and Batory, D. 2000. Mixin-based programming in C++. In 2nd Symposium on Generative and Component-Based Software Engineering (GCSE 2000). Erfurth, Germany.]]

10.1145/28697.28702

Steele , G. L. 1990. Common Lisp The Language , Second ed. Digital Press .]] Steele, G. L. 1990. Common Lisp The Language, Second ed. Digital Press.]]

Stefik M. and Bobrow D. G. 1985. Object-oriented programming: Themes and variations. The AI Magazine.]] Stefik M. and Bobrow D. G. 1985. Object-oriented programming: Themes and variations. The AI Magazine.]]

Stroustrup , B. 1986. The C+&plus ; Programming Language. Addison Wesley , Reading, Mass.]] Stroustrup, B. 1986. The C++ Programming Language. Addison Wesley, Reading, Mass.]]

Stroustrup , B. 1997. The C+&plus ; Programming Language, Third ed. Addison Wesley .]] Stroustrup, B. 1997. The C++ Programming Language, Third ed. Addison Wesley.]]

10.1145/320384.320408

10.1145/243439.243441

10.1145/302405.302457

10.1007/BF01806107

10.1145/38765.38828

VanHilst , M. and Notkin , D . 1996a. Using C++ Templates to Implement Role-Based Designs . In JSSST International Symposium on Object Technologies for Advanced Software. Springer Verlag, 22--37 .]] VanHilst, M. and Notkin, D. 1996a. Using C++ Templates to Implement Role-Based Designs. In JSSST International Symposium on Object Technologies for Advanced Software. Springer Verlag, 22--37.]]

10.1145/236337.236375

Wegner , P. and Zdonik , S. B . 1988. Inheritance as an incremental modification mechanism or what like is and isn't like . In Proceedings of ECOOP '88 , S. Gjessing and K. Nygaard, Eds. LNCS , vol. 322 . Springer-Verlag, Oslo, 55--77.]] Wegner, P. and Zdonik, S. B. 1988. Inheritance as an incremental modification mechanism or what like is and isn't like. In Proceedings of ECOOP '88, S. Gjessing and K. Nygaard, Eds. LNCS, vol. 322. Springer-Verlag, Oslo, 55--77.]]