Manish Pansiniya's Blog

.NET, C#, Javascript, ASP.NET and lots more…:)

Posts Tagged ‘How To Refactor

Refactoring Tip: Extract Method

leave a comment »

Refactoring code should be must part of the coding. There are many benefits to refactor your code. Some benefit you can see directly and some benefit will be seen when you get major changes from the client :). Sometimes client gives changes and it converted to Heart Attack automatically. LOL. But if you have followed good programming practices and has coded well, you have always a gr8 day (in your project. I could not say anything about evil in your personal life 🙂 ).

If I start writing book then it may take 2 years to share for the refactoring the code as it may contains patterns, practices, methods, standards etc to follow…

One of it is Extract Method. You need to extract the group of code into the understandable method. It will add bit overhead but that is negligible considering understanding and maintainability. Following is one example of Refactoring from the book. It is very basic example but you can understand the concept from the same

image

Written by Manish

April 18, 2009 at 12:54 am