Are DefType statments considered Bad Practice?

2020-03-24 08:51发布

问题:

I want your thoughts on why or (why not) this statement should (or should not) be used.

Since this is a little subjective, here is my criteria: Upvotes given for concrete reasons (as opposed to unreasoned opinion). Final answer accepted will be the most comprehensive answer.

回答1:

In a well-crafted program, Defxxx statements are pointless, because all variables and functions will be explicitly typed.

Except for one case: DefObj A-Z, in conjunction with Option Explicit, makes it (practically) impossible for any untyped or undeclared variable, function, or member to exist in your code, and makes anything that would wind up as a Variant stand out in sharp relief.

DefObj A-Z is the suspenders to Option Explicit's belt.