12
•
Use
a
list
of
code
patters
to
match
the
parser
classes.
For
instance,
ANTLR-‐generated
parsers
and
lexers
can
be
easily
recognized
by
subclassing
the
Parser
and
Lexer
classes
in
the
antlr
runtime
package.
For
example,
see
class
org.argouml.language.cpp.reveng.CPPParser
in
ArgoUML
(ver.
0.34).
Visitor
Class
Classes
instantiating
the
visitor
design
pattern
often
implements
a
lot
of
(usually
over-‐loaded)
visit
methods.
These
visit
method
can
introduce
a
lot
of
complexity,
and
interact
with
the
visited
structure,
which
often
merely
offers
data
to
the
visitor.
A
single
visitor
could
be
re-‐structured,
but
if
its
interface
contains
many
visit()
directives,
it
could
be
difficult
to
achieve
a
better
modularization.
Possible
detection
strategies:
•
The
class
name
contains
one
of
the
following
words:
“Visit”,
“Visitor”.
We
search
for
the
words
after
we
split
the
class
name
according
to
the
CamelCase
notation
for
Java
classes.
•
At
least
two
methods
of
the
class
contain
one
of
the
following
word:
“visit”,
“Visit”,
“visitor”,
“Visitor”.
We
search
for
the
words
after
we
split
the
class
name
according
to
the
CamelCase
notation
for
Java
methods.
•
The
call
graph
can
be
analysed
to
check
whether
the
call
sites
of
visit
methods
are
within
accept
methods
in
the
visited
class,
and
within
this
methods,
this
is
passed
as
a
single
parameter.
Persistence
Class
Classes
that
handle
persistence
in
a
system
tend
to
be
large
and
complex.
This
is
because
they
usually
interact
heavily
with
a
database.
Implementing
the
persistence
action
in
a
single
class
may
be
a
good
design
choice.
In
this
way,
it
is
simple
to
identify
the
classes
that
handle
the
persistence
and
to
modify
them.
Possible
detection
strategies:
•
At
least
half
of
the
visible
methods
(i.e.,
not
private
methods)
call
a
method
in
a
class
in
one
of
the
following
packages:
java.sql,
javax.sql
or
a
package
that
is
part
of
an
ORM
framework
such
as
hibernate,
batik
or
Eclipse
link.
F.
References:
[1]
M.
Fowler,
K.
Beck,
J.
Brant,
W.
Opdyke,
and
D.
Roberts,
“Refactoring:
Improving
the
Design
of
Existing
Code”.
Addison
Wesley,
1999.
[2]
M.
Lanza
and
R.
Marinescu,
“Object-‐Oriented
Metrics
in
Practice:
Using
Software
Metrics
to
Characterize,
Evaluate
and
Improve
the
Design
of
Object-‐Oriented
Systems”.
Springer,
2006.
[3]
M.
Abbes,
F.
Khomh,
Y.-‐G.
Guéhéneuc,
and
G.
Antoniol,
“An
empirical
study
of
the
impact
of
two
antipatterns,
Blob
and
Spaghetti
code,
on
program
comprehension”.
In:
Proceedings
of
CSMR,
2011,
pp.
181–190.