views:

27

answers:

1

Is there a shortcut that allows me to repoint all classes that use the old object and repoint them all to the new class that has the new object?

and i don't mean just doing a Ctrl+F then replace.

A: 

If they're all using a global variable, presumably they're referring to it as

TypeName.variableName

aren't they? Can't you just do a search and replace?

It's possible that the refactoring tools will help you with this too, but I suspect in this case a search and replace is just as easy.

EDIT: I've just tried myself, and it's certainly easy with Resharper: select the variable, right-click, Refactor, Move. Not sure about the native capabilities of VS2008 though.

Another option: change the design not to use a global variable in the first place. Dependency injection rocks :)

Jon Skeet
well, i'm trying to refactor an old code that inherited a particular class with properties, i wanted to make it so that its an entity instead of just an inherited class. its been reused so many times its ugly.
Martin Ongtangco
@Martin: That doesn't *sound* like a global variable... could you give a quick example of what you mean in the question?
Jon Skeet
sorry for that. what the old programmer did was, it created a Class that inherited a System.Web.Page. Inside it are properties like userIDs, names and it is shared on every web page on this project. the bad thing is, it had like 3 basepages with different uses. its a headache.
Martin Ongtangco
How exactly is it being "shared"? If you could give a sample of the code before and what you'd like it to look like afterwards, it would be easier to help you. It's likely that having ReSharper would be useful to you, btw...
Jon Skeet
anyway, i followed your suggestion. thanks!
Martin Ongtangco