Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Hungarian UIs

Hungarian UIs

Scheduled Pinned Locked Moved The Lounge
questionwpfdesigntutorial
67 Posts 39 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C c2423

    I think we can all agree that for the most part nobody uses Hungarian notation for variables any more... but it still seems prevalent in UI programming - for example I might have lblSomething next to txtSomething. On one hand I feel a bit uneasy that there must be some way to avoid this horrible practice, but on the other hand lblSomething is clearly meant to be a label which is next to txtSomething, and I need a way to differentiate between them without ending up with two controls with the same name. What say you? Disclaimer: I don't consider this to be a programming question, more a question of what styles people like to use.

    B Offline
    B Offline
    BobJanova
    wrote on last edited by
    #3

    If I have a control that is backing some data object field, let's say UserInfo.FirstName, I'll call it firstName or firstNameEdit, and its label firstNameLabel.

    C C 2 Replies Last reply
    0
    • L Lost User

      I don't do any UI programming - problem solved avoided.

      C Offline
      C Offline
      c2423
      wrote on last edited by
      #4

      Maybe I should have thought of that. I'll know for next time :)

      A 1 Reply Last reply
      0
      • B BobJanova

        If I have a control that is backing some data object field, let's say UserInfo.FirstName, I'll call it firstName or firstNameEdit, and its label firstNameLabel.

        C Offline
        C Offline
        c2423
        wrote on last edited by
        #5

        That feels equally iffy to me, and has the disadvantage of being more verbose...

        B 1 Reply Last reply
        0
        • C c2423

          I think we can all agree that for the most part nobody uses Hungarian notation for variables any more... but it still seems prevalent in UI programming - for example I might have lblSomething next to txtSomething. On one hand I feel a bit uneasy that there must be some way to avoid this horrible practice, but on the other hand lblSomething is clearly meant to be a label which is next to txtSomething, and I need a way to differentiate between them without ending up with two controls with the same name. What say you? Disclaimer: I don't consider this to be a programming question, more a question of what styles people like to use.

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #6

          I have been trying to get away from Hungarian for a loooong time, but I still use txtPassword and butOK and labPasswordPrompt. The original idea of HN was good - and I think it does help to distinguish UI controls with a prefix. If only to make it easier to find in intellisense! :laugh:

          The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          F 1 Reply Last reply
          0
          • C c2423

            I think we can all agree that for the most part nobody uses Hungarian notation for variables any more... but it still seems prevalent in UI programming - for example I might have lblSomething next to txtSomething. On one hand I feel a bit uneasy that there must be some way to avoid this horrible practice, but on the other hand lblSomething is clearly meant to be a label which is next to txtSomething, and I need a way to differentiate between them without ending up with two controls with the same name. What say you? Disclaimer: I don't consider this to be a programming question, more a question of what styles people like to use.

            S Offline
            S Offline
            S Houghtelin
            wrote on last edited by
            #7

            Oh no! The can-o-worms has been opened! Variables should be clear in what they are being used for, and it helps if one can tell the scope of the variable. Including some indication of variable type can be useful but in IDEs like Visual Studio a person can hover the mouse curser over a variable and the variable type can be easily determined. Now tabs vs spaces, there you're asking for real trouble...

            It was broke, so I fixed it.

            1 Reply Last reply
            0
            • C c2423

              I think we can all agree that for the most part nobody uses Hungarian notation for variables any more... but it still seems prevalent in UI programming - for example I might have lblSomething next to txtSomething. On one hand I feel a bit uneasy that there must be some way to avoid this horrible practice, but on the other hand lblSomething is clearly meant to be a label which is next to txtSomething, and I need a way to differentiate between them without ending up with two controls with the same name. What say you? Disclaimer: I don't consider this to be a programming question, more a question of what styles people like to use.

              V Offline
              V Offline
              Vivi Chellappa
              wrote on last edited by
              #8

              Ask Nagy Vilmos. He is the Hungarian around here.

              1 Reply Last reply
              0
              • C c2423

                I think we can all agree that for the most part nobody uses Hungarian notation for variables any more... but it still seems prevalent in UI programming - for example I might have lblSomething next to txtSomething. On one hand I feel a bit uneasy that there must be some way to avoid this horrible practice, but on the other hand lblSomething is clearly meant to be a label which is next to txtSomething, and I need a way to differentiate between them without ending up with two controls with the same name. What say you? Disclaimer: I don't consider this to be a programming question, more a question of what styles people like to use.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #9

                I use lblSomething. Certainly better than the default Label1.

                1 Reply Last reply
                0
                • C c2423

                  That feels equally iffy to me, and has the disadvantage of being more verbose...

                  B Offline
                  B Offline
                  BobJanova
                  wrote on last edited by
                  #10

                  Making it a suffix means that related controls (i.e. all the things for FirstName) come together. Doing it 'properly' you have a single control, called firstName, which has the editor and the label and exposes the right properties. But UI usually doesn't work out like that, so you will have several controls relating to the same concept. You have to use the type to differentiate them, and a suffix seems better than a prefix to me.

                  C 1 Reply Last reply
                  0
                  • C c2423

                    I think we can all agree that for the most part nobody uses Hungarian notation for variables any more... but it still seems prevalent in UI programming - for example I might have lblSomething next to txtSomething. On one hand I feel a bit uneasy that there must be some way to avoid this horrible practice, but on the other hand lblSomething is clearly meant to be a label which is next to txtSomething, and I need a way to differentiate between them without ending up with two controls with the same name. What say you? Disclaimer: I don't consider this to be a programming question, more a question of what styles people like to use.

                    K Offline
                    K Offline
                    Keith Barrow
                    wrote on last edited by
                    #11

                    I swapped for a while to Something for the text box SomethingLabel for the label of the text box (not necessarily a label control - literally the thing that acts as a label for something), It worked well, for one thing you don't have to remember to rename if the text box becomes a dropdown or a dropdown some radio buttons etc. It did also help enforce the discipline the the UI did UI work and the OM should be separated out: Username would be the control to handle the username, and couldn't be re-used to store the username in lieu of the model. It also adheres to guidance about not including type names in members. Most places I've worked at stick to the Hungarian notation, so I've pretty much swapped back.

                    Sort of a cross between Lawrence of Arabia and Dilbert.[^]
                    -Or-
                    A Dead ringer for Kate Winslett[^]

                    C 1 Reply Last reply
                    0
                    • C c2423

                      I think we can all agree that for the most part nobody uses Hungarian notation for variables any more... but it still seems prevalent in UI programming - for example I might have lblSomething next to txtSomething. On one hand I feel a bit uneasy that there must be some way to avoid this horrible practice, but on the other hand lblSomething is clearly meant to be a label which is next to txtSomething, and I need a way to differentiate between them without ending up with two controls with the same name. What say you? Disclaimer: I don't consider this to be a programming question, more a question of what styles people like to use.

                      S Offline
                      S Offline
                      Single Step Debugger
                      wrote on last edited by
                      #12

                      I’m using it not only with the UI components but with some parts of the framework. For example DataTable dtMyTable etc. It’s useful and I’m not planning to change it just because some new pompous fancy coding conventions. I strictly follow the languages naming conventions though. No matter if it’s C++, C# or Java.

                      There is only one Vera Farmiga and Salma Hayek is her prophet! Advertise here – minimum three posts per day are guaranteed.

                      1 Reply Last reply
                      0
                      • C c2423

                        I think we can all agree that for the most part nobody uses Hungarian notation for variables any more... but it still seems prevalent in UI programming - for example I might have lblSomething next to txtSomething. On one hand I feel a bit uneasy that there must be some way to avoid this horrible practice, but on the other hand lblSomething is clearly meant to be a label which is next to txtSomething, and I need a way to differentiate between them without ending up with two controls with the same name. What say you? Disclaimer: I don't consider this to be a programming question, more a question of what styles people like to use.

                        W Offline
                        W Offline
                        Wayne Gaylard
                        wrote on last edited by
                        #13

                        I have been using wpf with mvvm for the past 3 or 4 years now, and thankfully, that means I very rarely have to name any controls :)

                        When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman

                        1 Reply Last reply
                        0
                        • C c2423

                          I think we can all agree that for the most part nobody uses Hungarian notation for variables any more... but it still seems prevalent in UI programming - for example I might have lblSomething next to txtSomething. On one hand I feel a bit uneasy that there must be some way to avoid this horrible practice, but on the other hand lblSomething is clearly meant to be a label which is next to txtSomething, and I need a way to differentiate between them without ending up with two controls with the same name. What say you? Disclaimer: I don't consider this to be a programming question, more a question of what styles people like to use.

                          D Offline
                          D Offline
                          Dave Calkins
                          wrote on last edited by
                          #14

                          I've never quite understood how strongly some dislike hungarian notation. its just a style :)

                          C B 2 Replies Last reply
                          0
                          • C c2423

                            I think we can all agree that for the most part nobody uses Hungarian notation for variables any more... but it still seems prevalent in UI programming - for example I might have lblSomething next to txtSomething. On one hand I feel a bit uneasy that there must be some way to avoid this horrible practice, but on the other hand lblSomething is clearly meant to be a label which is next to txtSomething, and I need a way to differentiate between them without ending up with two controls with the same name. What say you? Disclaimer: I don't consider this to be a programming question, more a question of what styles people like to use.

                            J Offline
                            J Offline
                            Joe Woodbury
                            wrote on last edited by
                            #15

                            Giving a variable name passwordString or something comparable is not Hungarian notation. The original intent with Hungarian notation was that a very short prefix would indicate HOW the variable was used, not the actual type of the variable. Thus dX meant delta-X, not that X is an integer. This was quickly perverted into a monstrosity. Name variables with meaningful names is to be encouraged, though in my style most abbreviations are discouraged. In UI programming, I often use Label/Checkbox or some suffix to distinguish controls from data. In C++, I still use Hungarian in three distinct cases: I put a 'p' in front of pointers since the semantics are dramatically different. I put 'h' in front of naked handles for a similar reason--if I see a variable prefixed with an 'h', there better be a CloseHandle or equivalent nearby (code-wise). I also put "m_" in front of class member variables. Oddly I don't do this in C# (except lately since my current peers insist on using the "_" prefix for member variables.)

                            Richard Andrew x64R C J 3 Replies Last reply
                            0
                            • K Keith Barrow

                              I swapped for a while to Something for the text box SomethingLabel for the label of the text box (not necessarily a label control - literally the thing that acts as a label for something), It worked well, for one thing you don't have to remember to rename if the text box becomes a dropdown or a dropdown some radio buttons etc. It did also help enforce the discipline the the UI did UI work and the OM should be separated out: Username would be the control to handle the username, and couldn't be re-used to store the username in lieu of the model. It also adheres to guidance about not including type names in members. Most places I've worked at stick to the Hungarian notation, so I've pretty much swapped back.

                              Sort of a cross between Lawrence of Arabia and Dilbert.[^]
                              -Or-
                              A Dead ringer for Kate Winslett[^]

                              C Offline
                              C Offline
                              c2423
                              wrote on last edited by
                              #16

                              Good answer - got my 5, thanks!

                              1 Reply Last reply
                              0
                              • C c2423

                                I think we can all agree that for the most part nobody uses Hungarian notation for variables any more... but it still seems prevalent in UI programming - for example I might have lblSomething next to txtSomething. On one hand I feel a bit uneasy that there must be some way to avoid this horrible practice, but on the other hand lblSomething is clearly meant to be a label which is next to txtSomething, and I need a way to differentiate between them without ending up with two controls with the same name. What say you? Disclaimer: I don't consider this to be a programming question, more a question of what styles people like to use.

                                R Offline
                                R Offline
                                Ravi Bhavnani
                                wrote on last edited by
                                #17

                                c2423 wrote:

                                lblSomething is clearly meant to be a label which is next to txtSomething, and I need a way to differentiate between them without ending up with two controls with the same name

                                I do the same thing [insert](in WinForms code behind)[/insert] as I find it useful and it helps reduce coding errors.  I have no qualms about using it.  Also, it's strictly not Hungarian notation, since lbl and txt are not primitive data types. /ravi

                                My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

                                C 1 Reply Last reply
                                0
                                • D Dave Calkins

                                  I've never quite understood how strongly some dislike hungarian notation. its just a style :)

                                  C Offline
                                  C Offline
                                  c2423
                                  wrote on last edited by
                                  #18

                                  I think there's general agreement these days that it's not a good style, particularly if you want to change the underlying type of something without having to do a lot of renaming, aside from the aesthetics of it. However, everybody has seen the arguments for and against ad nauseum but I was curious as to what people do in the UI. One other exception that springs to mind is IInterface, which I don't have any problems with.

                                  M 1 Reply Last reply
                                  0
                                  • J Joe Woodbury

                                    Giving a variable name passwordString or something comparable is not Hungarian notation. The original intent with Hungarian notation was that a very short prefix would indicate HOW the variable was used, not the actual type of the variable. Thus dX meant delta-X, not that X is an integer. This was quickly perverted into a monstrosity. Name variables with meaningful names is to be encouraged, though in my style most abbreviations are discouraged. In UI programming, I often use Label/Checkbox or some suffix to distinguish controls from data. In C++, I still use Hungarian in three distinct cases: I put a 'p' in front of pointers since the semantics are dramatically different. I put 'h' in front of naked handles for a similar reason--if I see a variable prefixed with an 'h', there better be a CloseHandle or equivalent nearby (code-wise). I also put "m_" in front of class member variables. Oddly I don't do this in C# (except lately since my current peers insist on using the "_" prefix for member variables.)

                                    Richard Andrew x64R Offline
                                    Richard Andrew x64R Offline
                                    Richard Andrew x64
                                    wrote on last edited by
                                    #19

                                    So when you say you still use Hungarian in three cases, you are referring to the pre-monstrosity kind?

                                    The difficult we do right away... ...the impossible takes slightly longer.

                                    J 1 Reply Last reply
                                    0
                                    • C c2423

                                      I think we can all agree that for the most part nobody uses Hungarian notation for variables any more... but it still seems prevalent in UI programming - for example I might have lblSomething next to txtSomething. On one hand I feel a bit uneasy that there must be some way to avoid this horrible practice, but on the other hand lblSomething is clearly meant to be a label which is next to txtSomething, and I need a way to differentiate between them without ending up with two controls with the same name. What say you? Disclaimer: I don't consider this to be a programming question, more a question of what styles people like to use.

                                      M Offline
                                      M Offline
                                      M Badger
                                      wrote on last edited by
                                      #20

                                      I can't find it quickly but there was a good article posted here via the news feed (Insider News) that told a story, presumably true, as to what Hungarian was supposed to be for and what it got turned into and that they were vastly different. Anywho the Wikipedia article[^] might help, at least differentiating between System Hungarian and Apps Hungarian. Personally I tend to use the txtAge, lblAge, cmbGender, lblGender, cmdOK, cmdCancel etc. I am intrigued by the idea of switching to AgeTxt, AgeLbl, GenderCmb, GenderLbl, CancelCmd, OKCmd etc., might be better in at least some if not many places. Mike

                                      C L 2 Replies Last reply
                                      0
                                      • J Joe Woodbury

                                        Giving a variable name passwordString or something comparable is not Hungarian notation. The original intent with Hungarian notation was that a very short prefix would indicate HOW the variable was used, not the actual type of the variable. Thus dX meant delta-X, not that X is an integer. This was quickly perverted into a monstrosity. Name variables with meaningful names is to be encouraged, though in my style most abbreviations are discouraged. In UI programming, I often use Label/Checkbox or some suffix to distinguish controls from data. In C++, I still use Hungarian in three distinct cases: I put a 'p' in front of pointers since the semantics are dramatically different. I put 'h' in front of naked handles for a similar reason--if I see a variable prefixed with an 'h', there better be a CloseHandle or equivalent nearby (code-wise). I also put "m_" in front of class member variables. Oddly I don't do this in C# (except lately since my current peers insist on using the "_" prefix for member variables.)

                                        C Offline
                                        C Offline
                                        c2423
                                        wrote on last edited by
                                        #21

                                        Yes, I've read the Joel on Software article which explains the distinction, and agree in principle. In practice it's hard to get everyone on the team to go along with this... p for pointers makes sense, h for handles makes sense, m and underscore for member variables I change my mind on every few months - I dislike that there is a prefix in general, however the next alternative of caps/lower case first letter to distinguish feels equally smelly. I've actually got to the point of using automatic properties instead of backing fields mostly though so in newer framework versions this becomes less and less of an issue (using a private property may sound a bit wrong for what would have been a field, but that's an argument for another day)

                                        1 Reply Last reply
                                        0
                                        • R Ravi Bhavnani

                                          c2423 wrote:

                                          lblSomething is clearly meant to be a label which is next to txtSomething, and I need a way to differentiate between them without ending up with two controls with the same name

                                          I do the same thing [insert](in WinForms code behind)[/insert] as I find it useful and it helps reduce coding errors.  I have no qualms about using it.  Also, it's strictly not Hungarian notation, since lbl and txt are not primitive data types. /ravi

                                          My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

                                          C Offline
                                          C Offline
                                          c2423
                                          wrote on last edited by
                                          #22

                                          Strictly speaking strings aren't primitive data types either, but it'd make my skin crawl to name a variable strXyz.

                                          R L 2 Replies Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups