Changing the class name at design time

I'm in a situation where I have a "progress" class - the problem is that I'm interested in including some open source that also has a "progress" class. I very vaguely recall some references to an application capable of checking various files in development for a given class name ... and either return it ... or change it. Are you experiencing this?

thank

0


source to share


3 answers


Some languages ​​(C ++, C #) have a namespace concept. Java has packages. Python has modules. They are disabled to prevent class name collisions. Suppose you are talking about Java, an Open Source class called Progress is probably in its own package, and your Progress is in your own package. So maybe you don't have a problem as you thought you were doing.



Having said that, I am assuming you are asking about a function in the IDE called a refactor that will allow you to change your class name anywhere that references or has dependencies on it.

+2


source


Many IDEs (like Eclipse) can do this, but it's more common for Java and then PHP. Due to the dynamic nature of PHP variables, it is a little harder for the IDE to know exactly what needs to be changed. For example, you can do this:

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

      



The IDE will need to run your application to know that $ name contains "progress" at that particular moment. Even then, there would be no way to automatically fix it.

Unfortunately, you are stuck with search and replace. Do not worry; changing class names at design time is good. This forces you to rethink what the class is for.

0


source


Always prefix the class names with the product / project abbreviation. Why not use TextPad to replace all occurrences? Thus, you will not be confused in the future which class it is. I would also recommend using the namespace / package technology, but that will force you to rewrite a lot of the code I assume.

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

0


source







All Articles