Latest event in the Agile streak of Techies.ae was on Refactoring, practical scenarios given by Hammad Rajjoub. He has given a short synopsis of his talk at his blog. Taking a very keen interest in his blog and the fact that the event was very intensive and energetic we all came to the conclusion that refactoring involves a lot of common sense. More than the tools of trade: Resharper, and Refactor! Pro we agreed that looking at the business benefit first is the wisest move forward.
Before starting refactoring on existing apps we should get some form of unit testing in place to make sure we do not kill existing behaviour. Then we should look at code smells first coined by Martin Fowler in his book: “Refactoring: Improving the Design of Existing Code; Addison Wesley Longman; 1999; ISBN 0-201-48567-2” The list Hammad covered is stated on his blog entry. Some entries were well discussed and some were hammer pieces. All in all a good ground for sharing thoughts.
After the discussion part Andrew posted a challenge about changing interfaces and dependent libraries, to which Hammad and Anton immediately took up Visual Studio and showed the workings in practice. as it appeared you can change the interface and the implementation of a class and still use this ‘newer’ library as the source for another dependent library in .Net, but if an interface is changed and the implementing class is in a different library the app will not function. This to do with the way IL interprets the language, a class-reference is done based on named interface calls, hence when the interface does not change existing names but only adds interface properties or methods this delivers ‘backwards’ compatible libraries. so dependent libraries will not ‘break’.
So all in all we left the table a bit wiser and a lot more versed in refactoring.
Cannot leave with a nice snapshot so here goes!