Using Concepts Analysis For Mining Functional Features From Legacy Code Amal Elkharraz, Petko Valtchev, Hafedh Mili LATECE Laboratory, Universit´ e du Qu´ ebec ´ a Montr´ eal Montr´ eal, Canada ekharraz@iro.umontreal.ca, {hafedh.mili, petko.valtchev}@uqam.ca Abstract Legacy OO applications typically implement a number of functional features. In the absence of aspect-oriented de- velopment techniques to separately develop and maintain these features, they end up embodied in the same class hi- erarchies. That embodiement depends on the design tech- nique used to implement them. We identified three such design techniques: a) multiple inheritance– or simulations thereof, b) delegation, and c) what we referred to as ad- hoc implementation. We are interested in developing tech- niques for identifying and isolating code fragments that im- plement distinct functional features. Here, we explore the use of concept analysis to detect ad-hoc implementations of features. We present the principles underlying our over- all approach, a concrete method for identifying functional features in legacy code, and the results of preliminary ex- perimentation. Aspect-oriented development, aspect mining, refactor- ing, concept analysis, functional aspects. 1 Introduction Legacy OO applications typically implement a number of functional features. This kind of situation happens when several functional features are requested in the initial de- velopment, or when new functionalities are added during maintenance. For example, the same Employee class may be used by a payroll functionality, and thus needs to sup- port data and function members for things such as salary base, number of hours worked, and by a production plan- ning functionality, and thus needs to support function and data members related to skills, shifts, number of hours worked, and so forth. Our work is concerned with develop- ing techniques for identifying functional features in legacy OO code for those cases where several features affect the same classes. Minimally, this should help us understand the legacy application and maintain a given feature without in- terfering with the others. This should also help us refactor our application to repackage those features in such a way that they can be developed and maintained separately, and composed on demand. Ideally, our software abstraction and packaging technique should enable us to implement different functional features in distinct software artifacts that we can develop, maintain, and compose at will [10]. OO abstraction and packaging techniques enable us to separate object-specific features– by encapsulating them in classes– but do not adequately sepa- rate features that affect or crosscut the same set of classes. Aspect-oriented software development (AOSD) was meant to address this problem by proposing artifacts that enable us to untangle requirement types that OO abstractions could not. However, before/without such techniques, designers had to cope with multiple functional features by using tra- ditional OO language constructs or design idioms. Exam- ples of such idioms include multiple inheritance– through language built-in constructs or through design idioms– del- egation, or, using an ad-hoc implementation where no spe- cic care is taken to package the functional feature. Our strategy for identifying functional features relies, at least in part, on the detection of such programming and design id- ioms in legacy code. In this paper, we explore the use of concept analysis to identify instances of multiple functional features implemented in an ad-hoc manner. In the next section, we characterize what we mean by func- tional feature, and take a look at the problem of identifying functional features in legacy code. Section 3 deals speci- cally with ad-hoc implementations: what they are, and they can be detected. Section 4 introduces a family of algorithms for extracting functional features. The results of our pre- liminary experiments are discussed in section 5. We discuss related work in section 6, and conclude in section 7 with directions for further research. 2 Characterizing functional feature By functional feature, we mean a slice or “subset” of an OO application that addresses a cohesive subset of func- tional (domain) requirements. By functional requirement, 2009 21st IEEE International Conference on Tools with Artificial Intelligence 1082-3409/09 $26.00 © 2009 IEEE DOI 10.1109/ICTAI.2009.110 625