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

Consider specific Annotations for UserForms #6206

Closed
AlpsDevABE opened this issue Mar 22, 2024 · 2 comments
Closed

Consider specific Annotations for UserForms #6206

AlpsDevABE opened this issue Mar 22, 2024 · 2 comments
Assignees
Labels
enhancement Feature requests, or enhancements to existing features. Ideas. Anything within the project's scope. feature-inspections up-for-grabs Use this label in conjunction with a difficulty level label, e.g. difficulty-02-ducky

Comments

@AlpsDevABE
Copy link

What
When using Code Inspection for userforms the following items come up:

  • Consider renaming Control lblPassword
  • Consider renaming procedure cmdOk_Click

Ignoring these instances at Module level will apply '@IgnoreModule HungarianNotation
Which will suppress any internal variable from marking in the Code.

Why
I understand that Systems HungarianNotaion is bad however in user forms you often have multiple control elements representing as single object such as a Label, TextBox and maybe even a button or two. It becomes a nightmare to manage when there is such a bad mix of Data and Logic together and that is just the nature of userforms.

I would recommend something like '@IgnoreUserForm HungarianNotation which would suppress any references to things like lblPassword txtPassword if Password is a Form Control along with any functions that occur for that control without excluding the inspection for Real Code.

Example

'@IgnoreUserForm HungarianNotation 
' This code should not trigger the inspection:
Private Sub cmdCancel_Click()
  ' But this code should
  Dim strPotatoes as String
  strPotatoes = "Why systems hungarian, ugh!!"
End Sub
@AlpsDevABE AlpsDevABE added enhancement Feature requests, or enhancements to existing features. Ideas. Anything within the project's scope. feature-inspections up-for-grabs Use this label in conjunction with a difficulty level label, e.g. difficulty-02-ducky labels Mar 22, 2024
@retailcoder
Copy link
Member

Personally I've been spelling things out for a while:

  • TextBox: PasswordBox
  • Label: PasswordLabel
  • Button: CancelButton

I wouldn't go back to traditional prefixing, it reads so much more naturally.

I think a simple checkbox in the settings could take care of this without needing to introduce a new annotation.

@retailcoder
Copy link
Member

Note that the "Allowed identifiers" setting also allows listing Hungarian Notation prefixes, but the new checkbox allows not issuing inspection results specifically for userform controls without making names like lbl and btn legal for everything:

Image

@retailcoder retailcoder self-assigned this Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests, or enhancements to existing features. Ideas. Anything within the project's scope. feature-inspections up-for-grabs Use this label in conjunction with a difficulty level label, e.g. difficulty-02-ducky
Projects
None yet
Development

No branches or pull requests

2 participants