Login
Register
Tutorials
Forum
Career Development
Resources
Reviews
Jobs
Interview
Communities
Projects
Training
Silverlight Games
|
Bookmarks
|
New Members FAQ
|
Mentor
|
Code Converter
|
IT Companies
|
Peer Appraisal
|
Members
|
Revenue Sharing
|
Computer Jokes
|
New Posts
|
Social
|
Talk to Webmaster Tony John
Online Members
Raj.Trivedi
More...
Resources
»
Technical Tips
»
General
Know more about Code Refactoring
Posted Date:
29-Jun-2012
Category:
General
Author:
Prachi Kulkarni
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!
Tweet
Responses to "Know more about Code Refactoring"
No responses found. Be the first to respond...
Feedbacks
Post Comment:
Notify me by email when others post comments to this article.
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
Using Regular expressions..
Certifications for many languages
How to download Bing and Google search engine background image.
Quickly repair mobile dropped in water!
Outlook Express Tips and Tricks
Simple and usefull softwares for your computer
Popular Tags
Tag posting guidelines
Search Tags
Code refactoring
.
Follow us on Twitter:
https://twitter.com/dotnetspider
Active Members
Today
Pawan Awasthi
(49)
srirama
(7)
Phagu Mahato
(7)
Last 7 Days
baskar
(298)
Asheej T K
(173)
Ultimaterengan
(167)
more...
Awards & Gifts
Email subscription
.NET Jobs
.NET Articles
.NET Forums
Articles Rss Feeds
Forum Rss Feeds