Subscribe to Subscribers
Talk to Webmaster Tony John

Online Members

Raj.Trivedi
More...


Resources » Technical Tips » General

Know more about Code Refactoring


Posted Date:     Category: General    
Author: Member Level: Gold    Points: 15


This article will explain about code refactoring, When to do code refactoring and what are the things need to be taken care of while coding. Code refactoring is a technique for restructuring an existing body of code so that your application will give you higher performance. I hope it will be useful for you.



 


Know more about Code Refactoring
When it is necessory to do code refactoring?

If your application degrades the performance , you require code refactoring.
Find following areas/cases where you need to have code refactoring :
1) Long methods with long parameter lists.
2) Message list chains
3) Data clumps
4) Redundent code
5) Divergent change
what are the basic principles of code refactoring?
1) Seperation of Concerns (SOC)
2) Dependency Inversion
3) Single Responsibilty Principle (SRP)
4) Inversion of control (IOC)
What are the things which should be avoided?
1) Avoid writing long methods. Write small piece of code always and it should be self explainatory.
2) Write the comments in the code to clarify why this code is required to be there and not for what is explained in the code.
3) Avoid duplicate code in the application . If you want to have same code again and again then put that code in the common class.
4) Class should not contain long parameter lists. Pass necessory parameters only.
5) Class should not have too many instance variables. It degrades the performance of your application.
6) Always use small data objects.
7) Any change to handle variation should be in single class.
8) Use methods in the class more efficiently.
What are the refactoring techniques?
1) Exact method : Turn the fragment in to method whose name explains purpose of the method.
2) Replace Temp with Query : Replace the expression into the method. Replace all references of temp in to expression. Then the new method can be used in other methods.
3) Introduce parameter objects : Group of parameters can be replaced with proper object.
4) Pull down method
5) Replace parameters with method.
6) Replace type code with class / subclass.
7) Replace type code with state object.





Did you like this resource? Share it with your friends and show your love!


Responses to "Know more about Code Refactoring"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: Using Regular expressions..
    Previous Resource: How to downlaod your videos through Mozilla FireFox
    Return to Resources
    Post New Resource
    Category: General


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    Code refactoring  .  



    Follow us on Twitter: https://twitter.com/dotnetspider

    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.