Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Springer Science - 2005 - Reverse Engineering of Object Orie.pdf
Скачиваний:
17
Добавлен:
15.08.2013
Размер:
6.11 Mб
Скачать

18 1 Introduction

State diagrams and their recovery from the source code are presented in detail in Chapter 6.

1.7 Organization of the Book

The remainder of the book describes the algorithms that can be used to produce the diagrams presented in the previous sections for the eLib program, starting from its source code.

Most of the static analyses used to reverse engineer these diagrams share a common representation of the code called the Object Flow Graph (OFG). Such a data structure is presented in Chapter 2. This chapter contains the rules for the construction of the OFG and introduces a generic flow propagation algorithm that can be used to infer properties about the program’s objects. Specializations of the generic algorithm are defined for specific properties.

The basic algorithm for the recovery of the class diagram is presented at the beginning of Chapter 3. Here, the rules for the recovery of the various types of associations, such as dependencies and aggregations, are discussed. One problem of the basic algorithm for the recovery of the class diagram is that declared types are an approximation of the classes actually referenced in a program, due to inheritance and interfaces. An OFG based algorithm is described that improves the accuracy of the class diagram extracted from the source code, when classes belonging to a hierarchy or implementing interfaces are referenced by class attributes. Another problem of the basic algorithm is related to the usage of weakly typed containers. Associations determined from the types of the container declarations are in fact not meaningful, since they do not specify the type of the contained objects. It is possible to recover the information about the contained objects by exploiting a flow analysis defined on the OFG.

Chapter 4 describes a technique for the static identification of class instances (objects) in the code. The allocation points in the code are used to approximate the set of objects created by a program, while the OFG is used to determine the inter-object relationships. A dynamic method for the production of the object diagram is also presented. Then, the differences between static and dynamic approach are discussed.

Interaction diagrams are obtained by augmenting the object diagram with information about message exchange (method invocations). In Chapter 5, the sequence of method dispatches is considered and their ordering is represented in the two forms of the interaction diagrams: either as collaboration diagrams, which emphasize the message flows over the structural organization of the objects, or as sequence diagrams, which emphasize the temporal ordering. The numbering algorithm, used to order events temporally, is also described in this chapter. In order for the approach to scale to large systems, it is complemented by an algorithm to handle incomplete systems, and by a focusing technique that can be used to locate and visualize only the interactions of interest.

1.7 Organization of the Book

19

Chapter 6 deals with the partitioning of the possible values of an object’s attributes into equivalence classes, vital to testing, which are approximated by means of static code analysis. The effects of method invocations on the class attributes determine the state transitions, i.e., the possibility that a given method invocation changes the state of the target object. The usage of abstract interpretation techniques for state diagram recovery is presented in detail in this chapter.

Chapter 7 is focused on the package diagram. Packages represented in the package diagram are groupings of design entities (typically classes) identified in the previous steps. The relationships that hold among such entities are abstracted into dependences among the packages they belong to. Techniques for the identification of cohesive groups of classes, including clustering and concept analysis, are presented in this chapter.

The last chapter contains some considerations on the development of tools that implement the techniques presented in the previous chapters. Then, the eLib program is considered once again, to describe the usage of reverse engineering after change implementation. Reverse engineered diagrams help understand the overall program organization and locate the code portions subjected to change. They are also useful after implementing the change, in that they can be compared with the initial diagrams, thus revealing the impact of the change at the design level, possibly indicating the opportunity of refactoring interventions. Furthermore, they support testing by providing information for the generation of class and integration test cases. Reverse engineered diagrams for the eLib program obtained after its modification are commented in this chapter. Finally, a survey of the existing support and of the current practice in reverse engineering is provided in the last section, where a discussion on the future trends and perspectives concludes the book.

All central chapters (2 through 7) have a similar structure: after a theoretical presentation of the analysis algorithms, which usually includes small code fragments used as examples, the eLib program is used as input for the described techniques and a step by step execution of the algorithms is conducted on this program. A discussion of related work concludes each chapter.

This page intentionally left blank