Oorang
Oorang

Reputation: 6780

Are DefType statments considered Bad Practice?

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.

Upvotes: 4

Views: 205

Answers (1)

Jim Mack
Jim Mack

Reputation: 796

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.

Upvotes: 6

Related Questions