views:

95

answers:

3

Hi

I'm in a situation where I have the class "progress" - trouble is that I'm interested in incorporating some open source that also has the class "progress". I remember very vaguely some reference to an app that's able to inspect the various files in a development for a given class name ... and either return it ... or change it. Have you experience of this?

thanks

A: 

Many IDEs (e.g. Eclipse) can do this, but it's more common for Java then PHP. Because of the dynamic nature of PHP variables, it's a little harder for IDEs to know exactly what to change. For example, you could do this:

$name = "prog";
$name .= "ress";
$cls = new $name();

The IDE would have to actually run your app to know that $name contains "progress" at that particular moment. Even then there would be no way to automatically fix it.

So sadly, you're stuck with find-and-replace. Don't worry though; changing class names during development is a good thing. It forces you to re-think exactly what the class is for.

JW
+2  A: 

Some languages (C++, C#) have a notion of namespace. Java has packages. Python has modules. They are desgined to prevent class name collision. Assume you're talking about Java, the Open Source class called "Progress" probably is in its own package, and your "Progress" is in your own package. So maybe you are not having a problem as you thought you do.

Having said that, I'm guessing you're asking about a feature in an IDE which is called refactor that would allow you to change your class name everywhere that refers or has dependencies on it.

Khnle
A: 

Always prefix class names with the product/project abbreviation. Why not use TextPad to replace all occurrences? That way you won't be confused in future which class it is. I would also recommend using namespace/package technique but that would make you rewrite a lot of code I assume.

http://en.wikipedia.org/wiki/Code_refactoring The above link has a some tools used for refactoring.

fasih.ahmed