Composing Classes - Roles Vs Traits

Fernando Barbosa, Ademar Aguiar

Abstract

Code replication has significant drawbacks in system maintenance. Code replication can have its origins in the composition limitations of the language. Several proposals have tried to overcome these limitations. A popular one is traits. However, traits do not support state or visibility control. Static roles are also a way of composing classes that has the benefits of traits and offers state, visibility control and other advantages as block renaming. We compare both approaches on how they are used to compose classes, and how they can be used to reduce code replication caused by composition limitations. As a case study we will compare how both approaches can reduce code replication by detecting and removing code clones within the JHotDraw framework. Results show that roles are capable of reducing a larger amount of replicated code than traits.

References

  1. Apel, S., Kästner, C. (2009): An Overview of FeatureOriented Software Development, in Journal of Object Technology, vol. 8, no. 5, July-August 2009.
  2. Baldoni, M., Boella, G. van der Torre, L., (2007): Interaction between Objects in powerJava, journal of Object Technologies 6, 7 - 12.
  3. Barbosa, F. and Aguiar, A. (2012). Roles as Modular Units of Composition. In 7th International Conference on Evaluation of Novel Approaches to Software Engineering, June, 29-30, Wroclaw, Poland.
  4. Barbosa, F. and Aguiar, A. (2013). Using Roles to Model Crosscutting Concerns. In Aspect Oriented Software Devlopment (AOSD3), March 24-29, Fukuoka, Japan.
  5. Batory, D., Sarvela, J. N. and Rauschmayer, A., Scaling Step-Wise Refinement. IEEE TSE, 30(6), 2004.
  6. Baxter, I., Yahin, A. Moura, L., Sant'Anna, M. and Bier. L. (1998). Clone Detection Using Abstract Syntax Trees. In Proc. of Int. Conf. on Software Maintenance.
  7. Bracha, G. and Cook, W. (1990): Mixin-Based Inheritance. In Proceedings of the OOPSLA/ECOOP, pages 303-311, Ottawa, Canada. ACM Press.
  8. Ceccato, M., Marin, M., Mens, K., Moonen, L, Tonella, P. and Tourwe, T (2005). A qualitative comparison of three aspect mining techniques, Proc. of the Inter. Workshop on Program Comprehension, Washington.
  9. Cutsem, T., Bergel, A., Ducasse, S. and Meuter, W. (2009): Adding State and Visibility Control to Traits Using Lexical Nesting, Proc. of ECOOP 2009, Italy.
  10. Ducasse, S., Schaerli, N., Nierstrasz, O., Wuyts, R. and Black, A. (2004): Traits: A mechanism for finegrained reuse. In Transactions on Programming Languages and Systems.
  11. Ducasse, S., Wuyts, R., Bergel, A., and Nierstrasz, O. (2007): User-changeable visibility: Resolving unanticipated name clashes in traits. In Proceedings OOPSLA, New York, NY.
  12. Fanta, R., Rajlich, V. (1999): Removing Clones from the Code. Journal of Software Maintenance: Research and Practice, Volume 11(4):223-243.
  13. Flatt, M. and Felleisen, M. (1998) Units: Cool modules for HOT languages. In Proc. of PLDI, May 1998.
  14. Fowler, M., (1999), Refactoring: Improving the design of existing code, Addison-Wesley, Boston, MA, USA.
  15. Gamma, E., Helm, R., Johnson, R. and Vlissides, J., (1995): Design Patterns: Elements of Reusable ObjectOriented Software, Addison-Wesley.
  16. Griswold, W.G., Sullivan, K., Song, Y., Shonle, M., Tewari, N., Cai, Y., Rajan, H., 2006: Modular Software Design with Crosscutting Interfaces. IEEE Software 23(1), 51-60 (2006).
  17. Herrmann, S., (2005): Programming with Roles in ObjectTeams/Java. AAAI Fall Symposium: "Roles, An Interdisciplinary Perspective".
  18. Higo, Y., Kamiya, T., Kusumoto, S., Inoue. K. (2004): Refactoring Support Based on Code Clone Analysis. In Proceedings of the 5th International Conference on Product Focused Software Process Improvement (PROFES'04), Kansai Science City, Japan.
  19. Kamiya, T., Kusumoto, S. and Inoue, K. (2002), Ccfinder: a multilinguistic tokenbased code clone detection system for large scale source code, IEEE Trans. Softw. Eng. 28, no. 7.
  20. Kästner, C., Apel, S., Batory, D., 2007: A Case Study Implementing Features using AspectJ. In: 11th Inter. Conference of Software Product Line, Kyoto, Japan.
  21. Kiczales, G., Hilsdale, E., Hugunin, J., Kersten, M., Palm, J., Griswold. W. G., (2001): An overview of AspectJ. In proceedings of ECOOP 2001, Budapest, Hungary.
  22. Komondoor, R. and Horwitz SS. (2000): SemanticsPreserving Procedure Extraction. In Proceedings of the 27th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL'00), pp. 155-169, Boston, MA, USA.
  23. Krogdahl, S., Møller-Pedersen, B., Sørensen, F. (2005): Exploring the use of Package Templates for flexible reuse of Collections of related Classes, in Journal of Object Technology, vol. 8, no. 7.
  24. Mayrand, J., Leblanc, C. and 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.
  25. McDirmid, S., Flatt, M. and Hsieh, W.C. Jiazzi: new-Age Components for Old-Fashioned Java”, OOPSLA 2001.
  26. Mezini, M. and Ostermann, K. 2003. Conquering Aspects with Caesar. In Proc. of AOSD 2003, pages 90 - 99.
  27. Przybylek, A. /2011). Systems Evolution and Software Reuse in Object-Oriented Programming and AspectOriented Programming , TOOLS 2011, LNCS 6705.
  28. Quitslund, P. and Black, A. (2004): Java with traits - improving opportunities for reuse. In Proceedings of the 3rd International Workshop on Mechanisms for Specialization, Generalization and inheritance.
  29. Riehle, D. 2000. Framework Design: A Role Modeling Approach, Ph. D. Thesis, Swiss Federal Institute of technology, Zurich.
  30. Roy, C. and Cordy, J. (2007) A Survey on Software Clone Detection Research. Tech. Report 2007-451, School of Computing, Queen's University at Kingston.
  31. Scharli, N., Ducasse, S., Nierstrasz, O. and Black, A. (2003): Traits: Composable units of behavior. In Proceedings of ECOOP 2003, volume 2743 of Lecture Notes in Computer Science. Springer.
  32. Smith, C. and Drossopoulou, S. (2005): Chai: Traits for Java-like languages. In Proceedings of ECOOP 2005.
  33. Steimann, F., (2000): On the representation of roles in object-oriented and conceptual modeling. Data & Knowledge Engineering 35(1):83-106.
  34. Tamai, T., Ubayashi, N., and Ichiyama, R., (2007): Objects as Actors Assuming Roles in the Environment, in Software Engineering For MultiAgent Systems V, Lecture Notes In Computer Science, vol. 4408. Springer-Verlag, Berlin.
Download


Paper Citation


in Harvard Style

Barbosa F. and Aguiar A. (2013). Composing Classes - Roles Vs Traits . In Proceedings of the 8th International Conference on Evaluation of Novel Approaches to Software Engineering - Volume 1: ENASE, ISBN 978-989-8565-62-4, pages 63-73. DOI: 10.5220/0004424000630073


in Bibtex Style

@conference{enase13,
author={Fernando Barbosa and Ademar Aguiar},
title={Composing Classes - Roles Vs Traits},
booktitle={Proceedings of the 8th International Conference on Evaluation of Novel Approaches to Software Engineering - Volume 1: ENASE,},
year={2013},
pages={63-73},
publisher={SciTePress},
organization={INSTICC},
doi={10.5220/0004424000630073},
isbn={978-989-8565-62-4},
}


in EndNote Style

TY - CONF
JO - Proceedings of the 8th International Conference on Evaluation of Novel Approaches to Software Engineering - Volume 1: ENASE,
TI - Composing Classes - Roles Vs Traits
SN - 978-989-8565-62-4
AU - Barbosa F.
AU - Aguiar A.
PY - 2013
SP - 63
EP - 73
DO - 10.5220/0004424000630073