
tation link. A documentation link references a
description with possibilities to extend the
logic.
2. Add each interface of the target code as is to the
template by putting each code block in a section
identified by the keyword interface plus the
name of the role the interface plays.
3. For any annotation added to the source code (and
thus also to the target code) a definition must be
created or updated. There are two cases:
a. Appropriate Annotation definition not exis-
tent: Create it.
b. Otherwise: Update annotation definition if
changes are necessary and possible.
4. Implement handler routines for
a. extracting information from relevant annota-
tions and providing relating these information
to other annotations,
b. actions for which handlers do not exist, and,
c. executing precondition checks.
Step 3 of the above activities results in annota-
tion definitions. The annotations existent in the
source and target code are equivalent with respect to
their name, but maybe different concerning their
scope. The scope of an applied annotation is the
statement the annotation is applied above.
5 RELATED WORK
Relevant approaches cope with the issues code
transformation, code templates, annotations, and
program understanding. With Java 5 annotations
have been introduced as first-class language con-
structs (JSR 175). These annotations are restricted in
that they cannot be applied to arbitrary scopes (i.e.
single statements are out of the scope). (Jackpot)
browses Java source code for conformance with
generic rules and executes transformations on ASTs
automatically. Each rule contains a Java-statement to
be matched and specifies how to transform the
fragment. (Krahn+, 2006) introduce compilable
code templates to execute automated refactorings for
Java code via code generation. To include directives
into the template, comments are used. The approach
does not consider semantic information. FUJABA
(Niere+, 2006) aims at extending UML for specify-
ing method bodies and generating code from UML
diagrams up to the level of statements. Additionally,
the generation of UML diagrams from source code
is supported.
6 CONCLUSIONS AND FUTURE
WORK
This paper suggested introducing explicit semantics
to source code as a means for identifying the contex-
tual sense of program elements. Using annotations
as a vehicle for transporting semantic information,
an adaptation of current coding practices is pro-
posed. In turn, the definition of code pattern tem-
plates allows obtaining key information about a
pattern, including its structure, preconditions, trans-
formations and annotation definitions.
A code pattern template contains a lot of useful
information and allows recognizing synonymous
pieces of codes. When defining code templates,
variants of a pattern and variations of source code
have to be considered separately to a certain extent.
Reuse is possible but reflecting on the validity of
existing templates is important. There should be a
consolidation feature which puts common parts of
two similar templates into one master template and
adds the different parts by referencing them.
Currently, we are examining complex patterns in
order to demonstrate the practicability of the de-
scribed approach. Especially the capability to reason
about missing information/annotations is focused.
REFERENCES
Gamma, E., Helm, R., Johnson R., Vlissides, J. (1995):
Design Patterns: Elements of Reusable Object-
Oriented Software. Addison-Wesley.
JSR 175: A Metadata Facility for the Java Programming
Language. http://www.jcp.org/en/jsr/detail?id=175
Jackpot. http://jackpot.netbeans.org/index.html
Niere, J., Schäfer, W., Wadsack, J. P., Wendehals, L.,
Welsh, J. (2000): Towards Pattern-Based Design Re-
covery. Proceedings of the 22
nd
International Confer-
ence on Software Engineering, Limerick, Ireland, 241-
251
Krahn, H., Rumpe, B. (2006): Techniques For Light-
weight Generator Refactoring. In: Lämmel, R.,
Saraiva, J., Visser, J.: Proceedings of Summer School
on Generative and Transformational Techniques in
Software Engineering (LNCS 4143), Springer.
Meffert, K., Philippow, I. (2006): Supporting Program
Comprehension for Refactoring Operations with An-
notations. In: Fujita, H., Mejri, M. (eds.): New Trends
in Software Methodologies, Tools and Techniques -
Proceedings of the fifth SoMeT_06, Vol. 147, 48-67.
Taibi, T.; Chek Ling Ngo, D. (2003): Formal Specifica-
tion of Design Patterns – A Balanced Approach. In:
Journal of Object Technology, vol. 2, no. 4, July-
August 2003, S. 127-140.
ICSOFT 2007 - International Conference on Software and Data Technologies
366