Ziff-Davis Enterprise 
DevSource: Microsoft Developer Resource
Add OnsArchitectureLanguagesTechniquesUsing VSForums
 
Home arrow Using VS arrow Page 5 - Refactoring in Visual C# 2005
Refactoring in Visual C# 2005
By Joe Mayo

Rate This Article:
Add This Article To:
Refactoring in Visual C# 2005 - ' Removing Parameters '
( Page 5 of 5 )

Remove Parameters

When modifying code, you may notice that a parameter is no longer being used. If it isn't necessary to the operation of the method, there is no reason to keep it. You should implement a Remove Parameters refactoring to eliminate the unused parameter.

ADVERTISEMENT

You can implement the Remove Parameters method by right-clicking the parameter, selecting Refactor, and selecting Remove Parameter. Given the code in Listing 11, you'll see a Reorder Parameters dialog similar to the one shown in Figure 7.


Listing 11. When a method has unused parameters, you should implement a Remove Parameters refactoring to delete the parameters that are not used.

        public void PerformCalculation()
        {
            Console.WriteLine("result = " + PerformXYZCalculation(5));
        }

        private int PerformXYZCalculation(int p)
        {
            return 3 * 4;
        }

www.refactoring.com.

Additionally, it is important that you continue to perform unit tests while you refactor. Don't allow the automatic refactoring support to provide a false sense of security. If you aren't performing unit tests, now is the time to start. I use NUnit, which is a free open source graphical unit testing application that you can find at www.nunit.org.



 
 
>>> More Using VS Articles          >>> More By Joe Mayo
 



DevSource video
Devsource Video Series
Manipulating Society through Technology
Jeremy Bailenson, Director of the Virtual Human Interaction Lab at Stanford University, talks about virtual reality, avatars, Moore's law, how real world behaviors influence online reality, and societal manipulation through technology!
>> Play video
>> Read article
>> See all videos
DevLife Blog

Julia explores the Robotics Studio! (It's for more than you think.)

MSDev Blog

Messages for Bill Gates!

Make it Work
.NET makes runtime type checking a breeze. See what Peter has to say about it in this week's tips!
News
Microsoft Counts on App Support for Vista
Microsoft has taken pains to demonstrate that Windows Vista will have ample application support.
DevSource RSS FEEDS
XML Want an easy way to keep up with breaking tech news? And the Get DevSource headlines delivered to your desktop with RSS.