[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] Solving a non-trivial code duplication problem
|
(How) can the following non-trivial code duplication problem be solved with
AspectJ (or with other advanced reflection techniques in Java)?
I am analysing a large program with the goal of migrating it to an
aspect-oriented solution. In that program I find many occurrences of the
following implementation pattern. On the one hand, there is a method m,
implemented by a class A:
A : public X m(...) {
body_of_m_here
}
On the other hand there is a method n implemented by the same class A which
creates an anonymous inncer class of some other type, but where the method m
with exactly the same body is defined:
A : public Y n(...) {
... some other code ...
new Z(...) { public X m(...) { body_of_m_here } }
... some other code ...
}
Unfortunately I cannot divulge any details of the code but the pattern above
appears at least 20 times for different pairs of methods in the code. What I
want avoid is the code-duplication between each of those pairs of methods
(the definition of the method m is repeated literally in 2 different places
in the code). Can AspectJ or Java reflection offer a cleaner solution?
--
View this message in context: http://www.nabble.com/Solving-a-non-trivial-code-duplication-problem-tf4804421.html#a13744846
Sent from the AspectJ - users mailing list archive at Nabble.com.