Explicit Option makes declaring variables easier

Software ResiliencyCode Reliability

Why you should care

VB has specific behavior that enable the developer to use variables even if these variables have not been previously declared and typed. However, it is possible to avoid this default behavior using the Option Explicit : in this case, all variables will require a declaration prior use.
This provides 2 main benefits.
The first benefit is a lower memory consumption improving other all application’s performance. This is due to the fact that undeclared variables are automatically created as Variant (large memory consumption).
The second benefit is that this option helps the developer to detect typing errors when writing code.

Business Impacts

Option Explicit is recommended because it greatly increases productivity and makes the code more efficient and less consuming.

Production Risk

CAST Recommendations

Option Explicit is recommended for VB users as it allows for improving the business aspects of the application portfolios that are developed in the company.  As such, Option Explicit should be utilized in the company’s style guides that encourage developers to focus on lowering memory consumption and improving performance for their respective applications.

How we detect

This code insight retrieves all VB Modules and Frames not using the Option explicit.


CloudMemory, Network, & Disk Space Management

Physical Environments referenced in Code: Option Explicit ensures resources, and memory, are not being wasted when portfolios are being adopted for Cloud-Computing purposes.


About CAST and Highlight’s Code Insights

Over the last 25 years, CAST has leveraged unique knowledge on software quality measurement by analyzing thousands of applications and billions of lines of code. Based on this experience and community standards on programming best practices, Highlight implements hundreds of code insights across 15+ technologies to calculate health factors of a software.

See featuresHow it works