7. Refactoring is a disciplined
technique for restructuring an
existing body of code, altering its
internal structure without
changing its external behavior
19. A God Class centralizes too much intelligence
Class uses directly more than a
few attributes of other classes
ATFD > FEW
Functional complexity of the
class is very high
AND GodClass
WMC ! VERY HIGH
Class cohesion is low
TCC < ONE THIRD
006
ari nescu 2
L anza, M
24. you do not
Maybe uch it at all
need to to
God Class
in the last version
isGodClass(last)
AND Harmless God Class
Stable throughout
the history
Stability > 90%
4
Ratiu etal, 200
29. Provider2
service2()
Client Intermediary Provider
getProvider() service()
Provider3
service3()
this.intermediary.provider.service();
this.intermediary.provider2.service2();
this.intermediary.provider3.service3();
to str angers
eter : D on’t talk
of Dem
T he Law
30. Code
te Nav igation
E limina Provider2
service2()
Client Intermediary Provider
fullService() service()
Provider3
service3()
this.intermediary.fullService();
2
er etal 200
Demey
31. ge inte rfaces
ad to hu
t: This can le Provider2
Cavea service2()
Client Intermediary Provider
fullService() service()
Provider3
service3()
this.intermediary.fullService();
2
er etal 200
Demey
32. Middl e Man
R emove Provider2
service2()
Client Provider
service()
Provider3
service3()
this.provider.service();
this.provider2.service2();
this.provider3.service3();
Fow ler 1999
33. An Envious Method is more interested
in data from a handful of other classes
Method uses directly more than
a few attributes of other classes
ATFD > FEW
Method uses far more attributes
of other classes than its own
AND Feature Envy
LAA < ONE THIRD
The used quot;foreignquot; attributes
belong to very few other classes
FDP ! FEW
006
ari nescu 2
L anza, M
36. Data Classes are dumb data holders
Interface of class reveals data
rather than offering services
WOC < ONE THIRD
AND Data Class
Class reveals many attributes and is
not complex
006
ari nescu 2
L anza, M
48. Redistribute Transform conditionals
responsibilities to Polymorphism
Eliminate Split up Transform Client ...
Navigation Code God Class Type Checks
Move Behavior Introduce Null Object
Closer to Data