Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hungarian notation #30

Open
spartanatreyu opened this issue Oct 2, 2019 · 0 comments
Open

Hungarian notation #30

spartanatreyu opened this issue Oct 2, 2019 · 0 comments

Comments

@spartanatreyu
Copy link

Hungrian notation should be added to the list of notations in the docs/lexicon page.

Hungarian notation resembles "camelCase" and "PascalCase" with the exception that it has a prefix that denotes some additional semantic meaning (usually data type). For example:

  • pContractor is a pointer that points to a Contractor object.
  • bEmployed is a boolean representing whether someone is employed or not.
  • fHourlyPayRate is a float representing the amount a contractor is paid per hour.

Hungarian notation can be extended to include the scope that the variable exists within. For example:

  • m_iDaysWorked represents the number of days someone has worked for, that is stored as an integer and whose value is a member (meaning: is independent for each instance) of a class, in this case of contractor.
  • s_iNumberOfOpenContractorPositions represents the total number of contractor positions available, stored as an integer. Since this value would be the same for all instances of the contractor class, it is declared and assigned statically on the contractor class itself.

More info: https://en.wikipedia.org/wiki/Hungarian_notation.

Personal note: While hungarian notation is falling out of use thanks to more modern development environments and tooling, it is still prevelent in many older and/or larger projects. It is also worth being aware about to prevent confusion among developers from different backgrounds. For instance:

Programmer A creates a variable called iHaveCompletedCourse, and commits the code to a project. Some time later, Programmer B tries to use or updates the variable iHaveCompletedCourse and ends up encountering errors. Now they have to spend time trying to determine why a variable they think is an integer, is not accepting an integer value when in fact it was a boolean and the "i" is in fact refering to whether the user themselves have completed a course or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant