Visual Studio 2010!

Read now >

View Now
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.
ADVERTISEMENT
ADVERTISEMENT

 

DevSource.com: Your Source for Visual Studio on Facebook
ADVERTISEMENT
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.

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 Microsoft Visual Studio Articles          >>> More By Joe Mayo