Abstract
The presence of code replication can be a consequence of a lack in the composition mechanisms where classes are insufficient to reuse the code that is replicated. To extend the reuse of pieces of code some proposals have been made that try to compose classes using those pieces of code. In this paper we compare two of those approaches: Traits and Roles. We compare their compositions mechanisms and how we can use them to reduce code replication. To study the extent to which they reduce code replication we conducted a case study using the JHotDraw framework where we detect and remove code replication using each technique. Results from the case study show that roles have an advantage over traits, as they are capable of removing more code replication.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Fowler, M.: Refactoring: Improving the design of existing code. Addison-Wesley, Boston (1999)
Mayrand, J., Leblanc, C., Merlo, E.: Experiment on the Automatic Detection of Function Clones in a Software System Using Metrics. In: Proc. of the International Conference on Software Maintenance (1996)
Baxter, I., Yahin, A., Moura, L., Sant’Anna, M., Bier, L.: Clone Detection Using Abstract Syntax Trees. In: Proc. of Int. Conf. on Software Maintenance (1998)
Roy, C., Cordy, J.: A Survey on Software Clone Detection Research. Tech. Report 2007-451, School of Computing, Queen’s University at Kingston (2007)
Bracha, G., Cook, W.: Mixin-Based Inheritance. In: Proceedings of the OOPSLA/ECOOP, pp. 303–311. ACM Press, Ottawa (1990)
Ducasse, S., Schaerli, N., Nierstrasz, O., Wuyts, R., Black, A.: Traits: A mechanism for fine-grained reuse. Trans. on Programming Languages and Systems (2004)
Scharli, N., Ducasse, S., Nierstrasz, O., Black, A.: Traits: Composable units of behavior. In: Cardelli, L. (ed.) ECOOP 2003. LNCS, vol. 2743, pp. 248–274. Springer, Heidelberg (2003)
Apel, S., Kästner, C.: An Overview of Feature-Oriented Software Development. Journal of Object Technology 8(5) (July-August 2009)
Kiczales, G., Hilsdale, E., Hugunin, J., Kersten, M., Palm, J., Griswold, W.G.: An overview of aspectJ. In: Lindskov Knudsen, J. (ed.) ECOOP 2001. LNCS, vol. 2072, pp. 327–354. Springer, Heidelberg (2001)
Quitslund, P., Black, A.: Java with traits - improving opportunities for reuse. In: Proceedings of the 3rd International Workshop on Mechanisms for Specialization, Generalization and Inheritance (2004)
Smith, C., Drossopoulou, S.: chai: Traits for java-like languages. In: Gao, X.-X. (ed.) ECOOP 2005. LNCS, vol. 3586, pp. 453–478. Springer, Heidelberg (2005)
Riehle, D.: Framework Design: A Role Modeling Approach, Ph. D. Thesis, Swiss Federal Institute of technology, Zurich (2000)
Steimann, F.: On the representation of roles in object-oriented and conceptual modeling. Data & Knowledge Engineering 35(1), 83–106 (2000)
Herrmann, S.: Programming with Roles in ObjectTeams/Java. In: AAAI Fall Symposium: “Roles, An Interdisciplinary Perspective” (2005)
Tamai, T., Ubayashi, N., Ichiyama, R.: Objects as Actors Assuming Roles in the Environment. In: Choren, R., Garcia, A., Giese, H., Leung, H.-f., Lucena, C., Romanovsky, A. (eds.) SELMAS. LNCS, vol. 4408, pp. 185–203. Springer, Heidelberg (2007)
Barbosa, F., Aguiar, A.: Using Roles to Model Crosscutting Concerns. In: Aspect Oriented Software Devlopment (AOSD3), Fukuoka, Japan, March 24-29 (2013)
Van Cutsem, T., Bergel, A., Ducasse, S., De Meuter, W.: Adding State and Visibility Control to Traits Using Lexical Nesting. In: Drossopoulou, S. (ed.) ECOOP 2009. LNCS, vol. 5653, pp. 220–243. Springer, Heidelberg (2009)
Ducasse, S., Wuyts, R., Bergel, A., Nierstrasz, O.: User-changeable visibility: Resolving unanticipated name clashes in traits. In: Proceedings OOPSLA, New York, NY (2007)
Fanta, R., Rajlich, V.: Removing Clones from the Code. Journal of Software Maintenance: Research and Practice 11(4), 223–243 (1999)
Komondoor, R., Horwitz, S.S.: Semantics-Preserving Procedure Extraction. In: Proceedings of the 27th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2000), Boston, MA, USA, pp. 155–169 (2000)
Higo, Y., Kamiya, T., Kusumoto, S., Inoue, K.: Refactoring Support Based on Code Clone Analysis. In: Bomarius, F., Iida, H. (eds.) PROFES 2004. LNCS, vol. 3009, pp. 220–233. Springer, Heidelberg (2004)
Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley (1995)
Kamiya, T., Kusumoto, S., Inoue, K.: Ccfinder: a multilinguistic tokenbased code clone detection system for large scale source code. IEEE Trans. Soft. Eng. 28(7) (2002)
Ceccato, M., Marin, M., Mens, K., Moonen, L., Tonella, P., Tourwe, T.: A qualitative comparison of three aspect mining techniques. In: Proc. of the Inter. Workshop on Program Comprehension, Washington (2005)
Barbosa, F., Aguiar, A.: Roles as Modular Units of Composition. In: 7th International Conference on Evaluation of Novel Approaches to Software Engineering, Wroclaw, Poland, pp. 29–30 (June 2012)
Baldoni, M., Boella, G., van der Torre, L.: Interaction between Objects in powerJava. Journal of Object Technologies 6, 7–12 (2007)
Batory, D., Sarvela, J.N., Rauschmayer, A.: Scaling Step-Wise Refinement. IEEE TSE 30(6) (2004)
Krogdahl, S., Møller-Pedersen, B., Sørensen, F.: Exploring the use of Package Templates for flexible reuse of Collections of related Classes. Journal of Object Technology 8(7) (2005)
Steimann, F.: The paradoxical success of aspect-oriented programming. In: Proceedings of the 21st Annual Conference OOPSLA 2006 (2006)
Przybyłek, A.: Systems Evolution and Software Reuse in Object-Oriented Programming and Aspect-Oriented Programming. In: Bishop, J., Vallecillo, A. (eds.) TOOLS 2011. LNCS, vol. 6705, pp. 163–178. Springer, Heidelberg (2011)
Kästner, C., Apel, S., Batory, D.: A Case Study Implementing Features using AspectJ. In: 11th Inter. Conference of Software Product Line, Kyoto, Japan (2007)
Griswold, W.G., Sullivan, K., Song, Y., Shonle, M., Tewari, N., Cai, Y., Rajan, H.: Modular Software Design with Crosscutting Interfaces. IEEE Software 23(1), 51–60 (2006)
Mezini, M., Ostermann, K.: Conquering Aspects with Caesar. In: Proc. of AOSD 2003, pp. 90–99 (2003)
McDirmid, S., Flatt, M., Hsieh, W.C.: Jiazzi: new-Age Components for Old-Fashioned Java. In: OOPSLA 2001 (2001)
Flatt, M., Felleisen, M.: Units: Cool modules for HOT languages. In: Proc. of PLDI (May 1998)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2013 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Barbosa, F., Aguiar, A. (2013). Comparing Two Class Composition Approaches. In: Filipe, J., Maciaszek, L.A. (eds) Evaluation of Novel Approaches to Software Engineering. ENASE 2013. Communications in Computer and Information Science, vol 417. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-54092-9_7
Download citation
DOI: https://doi.org/10.1007/978-3-642-54092-9_7
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-54091-2
Online ISBN: 978-3-642-54092-9
eBook Packages: Computer ScienceComputer Science (R0)