of using traditional graph transformation approaches
we investigate language specific issues; we omitted
NACs and used OCL to check conditions instead.
In the rest of this section we will concentrate on
the preprocessor side. People working on C or C++
analyzers are confronted by the problem of preproces-
sor directives. The usual approach is to work on pre-
processed code, or to recognize (partially handle) di-
rectives (Understand for C++ Homepage, 2008). Sev-
eral preprocessor-related refactorings can be found in
(Garrido and Johnson, 2002), which have no connec-
tion with the C language itself but with the prepro-
cessing directives. The key aspects of such refactor-
ings were presented at a conceptual level only, using
source code examples. Dealing with directives is eas-
ier, when preprocessor constructs form complete syn-
tactical units. Vittek (Vittek, 2003) introduced a tool
which implements some preprocessor-safe refactor-
ings on C++, while he acknowledged that there are
unhandled cases caused by complex code construc-
tions of the two languages. What makes this paper
special are three points. The first is that directives
are the main subject of refactoring at the model level.
Secondly, the graph transformation approach is sup-
ported by OCL. Thirdly, we have tried to narrow the
gap between academic research and industry by work-
ing on reverse-engineered program models.
4 CONCLUSIONS
Each modification of an existing program holds the
possibility of making errors. So does refactoring, the
technique for improving the quality of existing pro-
gram code. In this paper a method was introduced
to carry out program refactoring at the model level
to assure the safety of modifications. The subjects
of the refactorings were the preprocessor directives,
which are usually omitted from C/C++ program anal-
ysis, however ignoring directives may lead to errors
in analysis and transformation. As a demonstration of
the approach, the add parameter refactoring for pre-
processor macros was investigated at schematic and
concrete level. Experiments were performed on re-
verse engineered models derived from several small,
but real-life C/C++ programs. Future plans include
the performance improvement by separating the de-
sign and validation and the execution of refactorings.
ACKNOWLEDGEMENTS
This work was supported, in part, by grants no. RET-
07/2005, OTKA K-73688 and TECH 08-A2/2-2008-
0089.
REFERENCES
Bottoni, P., Parisi-Presicce, F., and Taentzer, G. (2004).
Specifying integrated refactoring with distributed
graph transformations. LNCS, 3062:220–235.
Fanta, R. and Rajlich, V. (1998). Reengineering object-
oriented code. In Proceedings of ICSM 2008, page
238, Washington, DC, USA. IEEE Computer Society.
Ferenc, R., Besz
´
edes,
´
A., Tarkiainen, M., and Gyim
´
othy,
T. (2002). Columbus - reverse engineering tool and
schema for C++. In ICSM 2002, pages 172–181, Mon-
treal, Canada. IEEE Computer Society.
Fowler, M. (2002). Refactoring Improving the Design of
Existing Code. Addison-Wesley.
Garrido, A. and Johnson, R. (2002). Challenges of refac-
toring C programs. In Proceedings of IWPSE 2002,
pages 6–14. ACM.
Gogolla, M. (2000). Graph Transformations on the UML
Metamodel. In GVMT’2000, pages 359–371. Carleton
Scientific, Waterloo, Ontario, Canada.
Gogolla, M., B
¨
uttner, F., and Richters, M. (2007). USE: A
UML-based specification environment for validating
UML and OCL. Sci. Comp. Program., 69(1-3):27–34.
jFactor (2009). Homepage of jFactor. http://old.instantia-
tions.com/jfactor/.
Mens, T. and Tourw
´
e, T. (2004). A survey of software refac-
toring. IEEE Transactions on Software Engineering,
30(2):126–139.
Mens, T., Van Eetvelde, N., Demeyer, S., and Janssens, D.
(2005). Formalizing refactorings with graph transfor-
mations. JSME: Research and Practice, 17:247–276.
Opdyke, W. F. (1992). Refactoring Object-Oriented Frame-
works. PhD thesis, Urbana-Champaign, IL, USA.
Refactoring Catalog (2009). Refactoring catalog.
http://www.refactoring.com/catalog/.
Roberts, D., Brant, J., and Johnson, R. (1997). A refac-
toring tool for Smalltalk. Theor. Pract. Object Syst.,
3(4):253–263.
Slickedit Homepage (2009). Homepage of Slickedit.
http://www.slickedit.com/.
Taentzer, G., M
¨
uller, D., and Mens, T. (2007). Specifying
domain-specific refactorings for AndroMDA based on
graph transformation. In AGTIVE, pages 104–119.
Understand for C++ Homepage (2008). Understand for
C++ Homepage. http://www.scitools.com.
Vid
´
acs, L., Besz
´
edes, A., and Ferenc, R. (2004). Columbus
Schema for C/C++ Preprocessing. In Proceedings of
CSMR 2004, pages 75–84. IEEE Computer Society.
Vid
´
acs, L., Gogolla, M., and Ferenc, R. (2006). From
C++ Refactorings to Graph Transformations. In Proc.
ICGT’2006 Workshop SETRA’2006, pages 127–141.
Vittek, M. (2003). Refactoring browser with preprocessor.
In Proceedings of CSMR 2003, pages 101–110, Ben-
evento, Italy.
REFACTORING OF C/C++ PREPROCESSOR CONSTRUCTS AT THE MODEL LEVEL
237