Avoid Hungarian Notation in Public Interfaces

Avoid Hungarian Notation in Public Interfaces

Most coding standards recommend the use of Hungarian variable naming, which uses prefixes to indicate the variable’s type. However, these naming conventions usually should not be used in a component’s public interface. Consider the following function:

    Public blnCheckStuff(intStuff As Integer) As Boolean


What if you need to change intStuff to a Variant? If you changed the name of intStuff to be consistent with its new type, code using named arguments need to change:

    bResult = blnCheckStuff(intStuff:=1)


So, you would either have to make changes to callers to blnCheckStuff or leave the confusing and inconsistent name alone. Additionally, using Hungarian notation in a public interface betrays implementation details to the outside world, which doesn’t really follow the Encapsulation part of OO.

In most cases, a better approach would be to do a good job documenting your component and use this declaration:

    Public CheckStuff(Stuff As Integer) As Boolean


Users of your component will still be able to tell what types to use by using Intellisense or the Object Browser.

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved