Yesterday, 10th Feb 2010, i was invited to speak at a Techies UG event, here in Dubai, UAE.
I started off the discussion with defining the practice of refactoring and i quoted Martin Fowler’s blog as following
•Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior.
•Its heart is a series of small behavior preserving transformations.
•Each transformation (called a ‘refactoring’) does little, but a sequence of transformations can produce a significant restructuring.
After this we moved on to the best practices for refactoring classes. Following is a list that we discussed:-
- Long Method
- Long Parameter List
- Duplicate Code
- Large Class
- Type Embedded In Name
- Un Communicative Names
- Inconsistent Names
- Speculative Generality
The session was very intense with everyone chipping in with their comments and i thoroughly enjoyed hosting it. Towards the end Anton and I wrote couple of code snippets to check the Andrew idea of using Interfaces (more on it later on). Rolf also chipped in with his comments and critiques. Notable absentees were Ron and Zubair and it would have been much more fun had they attended the event.
ps: watch out this post for snaps from the event.