Tech Tip: Find Unused: Another Case for Typing Everything
PRODUCT: 4D | VERSION: 12 | PLATFORM: Mac & Win
Published On: September 10, 2010
4D v12 features two new types of searches:
- Find Unused Methods and Global Variables
- Find Unused Local Variables
Find Unused Methods and Global Variables will search the entire database for Project Methods, Interprocess variables, and Process variables that are "unused". The definition of "unused" is covered in the 4D v12 Upgrade Reference but, in general, it means the object is declared but never actually used.
Find Unused Local Variables performs the same task, but locates local variables that are not used within their containing method.
On the surface it might appear that these searches are really about "style", in the sense of having "clean" code that doesn't contain un-used objects. In other words having a few extra variables declared that are never used is not really a big deal in terms of database functionality, though it might drive a more obsessive developer crazy.
On the other hand there has been a tendency for some developers to not use the Compiler option "All varaibles are typed" because:
- It requires diligence in typing variables.
- It requires Compiler methods which can tend to get "messy".
No 4D feature can address the former issue, though the Compiler can certainly catch you when it happens. But the Find Unused searches are very useful for cleaning up Compiler methods that might contain a plethora of un-used objects over the course of database design.
Certainly allowing 4D to automatically type variables is a convenient feature. The huge advantage to using the "All variables are typed" compiler option though is that the compiler becomes more strict and will therefore catch more programming mistakes. The Find Unused features are thus another way to make the transition to having cleaner, accurately typed code easier.
See Also: