Why shouldn't I use "Hungarian Notation"?
Categories:
The Decline of Hungarian Notation: Why Modern Code Prefers Clarity

Explore the historical context, perceived benefits, and ultimate drawbacks of Hungarian Notation, and understand why contemporary programming practices favor more descriptive naming conventions.
Hungarian Notation, a naming convention where a prefix indicates a variable's type or intent, was once a widely adopted practice in software development. Originating from Microsoft in the 1970s and 80s, it aimed to improve code readability and prevent type errors, especially in languages lacking strong type checking. However, as programming languages evolved and development practices matured, the perceived benefits of Hungarian Notation began to wane, giving way to a preference for more semantic and less verbose naming schemes. This article delves into the reasons behind its decline and why most modern developers advise against its use.
What is Hungarian Notation?
Hungarian Notation comes in two primary forms: Apps Hungarian and Systems Hungarian. Apps Hungarian (also known as 'Kind' Hungarian) prefixes variables with an abbreviation indicating their kind or purpose, such as rw
for 'row' or col
for 'column'. Systems Hungarian, the more common and controversial form, prefixes variables with their data type, like i
for integer, sz
for null-terminated string, or b
for boolean. The idea was that by embedding type information directly into the variable name, developers could quickly understand its nature and avoid common programming mistakes.
int iCount; // 'i' for integer
char* szName; // 'sz' for null-terminated string
bool bIsValid; // 'b' for boolean
HWND hWnd; // 'h' for handle, 'wnd' for window
Examples of Systems Hungarian Notation in C/C++
The Perceived Benefits and Their Erosion
In its heyday, Hungarian Notation offered several advantages, particularly in environments with limited tooling and less sophisticated languages:
- Type Awareness: In weakly typed languages or those without robust IDE support, prefixes served as a constant reminder of a variable's type, helping prevent type-mismatch errors.
- Readability (Initial): For developers familiar with the convention, it could initially make code easier to parse by quickly conveying variable properties.
- Refactoring Aid: When changing a variable's type, the prefix would also need to change, signaling a necessary code review.
However, these benefits largely eroded with advancements in programming languages and development tools. Stronger type systems, advanced IDEs with intelligent auto-completion and type inference, and sophisticated debuggers made explicit type prefixes redundant. The need for manual type tracking diminished significantly.
flowchart TD A[Weakly Typed Languages] --> B{Manual Type Tracking Needed} B --> C[Hungarian Notation Adopted] C --> D[Initial Readability & Error Prevention] D --> E[Modern Languages & IDEs Emerge] E --> F{Automated Type Checking & Inference} F --> G[Hungarian Notation Becomes Redundant] G --> H[Focus Shifts to Semantic Naming]
Evolution of programming practices and the decline of Hungarian Notation
Key Reasons Against Using Hungarian Notation Today
The arguments against Hungarian Notation are compelling and have led to its widespread deprecation in modern coding standards:
- Redundancy with Modern Tools: Most contemporary IDEs provide instant type information on hover, during auto-completion, and through static analysis. Explicitly encoding type in the name becomes visual noise.
- Maintenance Burden: If a variable's type changes (e.g., from
int
tolong
, orstring
toStringBuilder
), its name must also change. This creates unnecessary refactoring work and potential for inconsistencies if not updated everywhere. - Obfuscation of Intent: The primary purpose of a variable name should be to describe what it represents or why it exists, not how it's stored. Prefixes often distract from the variable's semantic meaning.
- Inconsistency and Ambiguity: There's no universal standard for Hungarian Notation prefixes, leading to different conventions across projects or even within the same codebase. What does
s
mean? String? Size? Status? This ambiguity can hinder collaboration. - Type System Evolution: As languages introduce new types (e.g.,
var
in C#,auto
in C++,any
in TypeScript), or as types become more complex (generics, custom classes), creating meaningful and consistent prefixes becomes increasingly difficult or impossible. - Focus on Implementation Details: Good code abstracts away implementation details. Hungarian Notation exposes these details in variable names, making the code less resilient to changes in underlying data structures or types.
customerAge
is far more descriptive and maintainable than iCustAge
. The type (int
) is an implementation detail that your IDE or compiler already knows.Modern Alternatives: Semantic Naming and Strong Typing
Instead of Hungarian Notation, modern best practices emphasize:
- Descriptive, Semantic Names: Variable names should clearly convey their purpose and meaning within the business domain. For example,
totalSalesAmount
instead ofdTotalSalesAmt
. - Strong Type Systems: Rely on the language's type system and compiler to enforce type correctness. This is more robust and less error-prone than manual naming conventions.
- IDE Support: Leverage the powerful features of modern Integrated Development Environments (IDEs) for type inference, refactoring, and error checking.
- Code Reviews: Peer code reviews are an excellent way to catch logical errors and ensure naming consistency and clarity, far more effectively than relying on prefixes.
int count = 0; // Clear, descriptive name
string userName = ""; // Intent is obvious
bool isValid = false; // Self-documenting
Window mainWindow; // Custom type, no prefix needed
Modern, semantic naming conventions in C#
While Hungarian Notation served a purpose in a different era of software development, its utility has largely been superseded by advancements in programming languages and tools. Adopting clear, semantic naming conventions, coupled with the power of modern IDEs and strong type systems, leads to more readable, maintainable, and robust codebases.