Friday, October 26, 2012

Is this item still in use?

As projects get bigger, it's easy to end up creating stuff you don't actually use. If you ever suspect that a particular window, webpage, class, module, control, method, property, or just about anything, is not really being used there's an easy way to find out.
  1. First, rename the item. You can do this by just adding an extra letter ("x" for example) to the end of the name.
  2. Run your app.
If the item whose name you changed is being used anywhere in your code, the compiler won't be able to find it by its old name and will generate a compile error. Specifically, the message is:

 If you get no compile errors, then the item is not being used and can be deleted.

There are some exceptions to this. If the item is a window or webpage and you don't refer to it in code but it is selected as the default Window or WebPage, renaming it won't cause an error. The same holds true for menubars. However, these are items you almost certainly know are in use anyway.

1 comment:

Beatrix Willius said...

This is a highly sophisticated method. How about making us users with big projects (>500 classes) something nicer like a special report which does this for ALL classes?