For future reference, here are few things to look for during refactoring the source.
- Lots of comment explaining a piece of code -> Extract the code in a separate method
- When comment explains preconditions -> Use Assertions
- Look for comments to extract methods
- Extract methods semantically
- Extract class if there are too many responsibilities
- Extract interface if you can identify subset of features that clients can use
Long Parameter List
- See if the method is being used to do more than 1 action and the logic is controlled by the parameters ( eg. Add/Update in a single method )
- If the parameters come from a single object, pass the object or extract an object out of parameters
- Avoid Hungarian notations
- Name the method so that it communicates to other people ( Avoid One or Two Character names, Numbered variables, Odd abbreviations, Misleading names )
- Dead code
- YAGNI principle ( avoid unnecessary generalization )
- Magic Number -> Replace numbers inside code body into symbolic constants
- Extract Methods to pull duplication code and put it inside the most appropriate class. Otherwise, extract a class and use it.
- Combine classes if two classes are doing mostly similar stuff.