FREE BOOK

Chapter 6: Improving Class Quality

Posted by Packt Publishing Free Book | Visual Studio 2010 September 15, 2010
In this chapter we will see how to refactor our code to be more cohesive and less coupled.

Refactoring assemblies

When approaching refactoring assemblies by moving classes from one to another, the best starting point is to have all the projects associated with those assemblies in one Visual Studio solution. Often, systems already have this type of organization. Larger projects may have to avoid this specific organization for performance and usability reasons within Visual Studio. A temporary solution that contains these projects, in these cases, is the recommended place to start. When dealing with many project files, this may cause a bit of grief creating and loading the solution, but it will give a huge payoff if you want to move more than a couple of classes.

When approaching performing the Move Type to new Namespace from a single solution, performing the refactoring within Visual Studio® becomes very simple. Moving a class from one project to another becomes a simple process of selecting it in the Solution Explorer and dragging it to another project folder and dropping it while holding the Shift key down. Holding the Shift key down while dropping causes a move to occur instead of a copy. Once copied, the new file should be edited to change the original namespace to the destination namespace.

Total Pages : 17 910111213

comments