|
When is it necessary to rearrange your
code
Does factoring require special methods? We know it requires testing.
Here are some re-factoring methods listed by code 'smells'.
|

|
dreams
home
bookshop
music shop
meal menus
adventure
photos
links
about us

|
- Duplicate Code
- main reason to refactor
- Long Method
- inherited from procedural programming
- Large Class
- too much done by a single class
- Long Parameter List
- are no longer necessary when working with objects
- Divergent Change
- one class is commonly changed in different ways for different reasons
- Shotgun Surgery
- changes influence to many classes and methods
- Feature Envy
- too much interest in other objects data
- Data Clumps
- data that is used together everywhere would make a great class of
its own
- Primitive Obsession
- use classes in addition or instead of primitive data types
- Switch Statements
- object orientation has other ways to deal with actions depending
on types
- Parallel Inheritance Hierarchies
- sometimes useful but often unnecessary
- Lazy Class
- A class that isn't doing enough to pay for itself should be eliminated.
- Speculative Generality
- don't invest to much in flexibility for the future
- Message Chain
- hard couple the client to the structure of navigation
- Middle Man
- should be removed if delegation is all he does
- Inappropriate Intimacy
- restricting the knowledge of the internals of other classes
- Incomplete Library Class
- must sometimes be extended to add wanted functionality
- Data Class
- should get additional tasks which deal with its data to raise its
importance
- Refused Bequest
- if subclasses use only very little of what they are given by their
parents
- Comments
- a comment is a good place to say why you did something not
what you did
|
| If you like what you
read, click
here to sign up for our mailing list.and we'll notify you when we post
new book reviews ________________________________________
all text and images
© Copyright 1997-2001 George D. Girton.
All Rights Reserved.
|