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. One-garian Notation

One-garian Notation

Scheduled Pinned Locked Moved The Lounge
csharpcomquestion
61 Posts 24 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.
  • OriginalGriffO OriginalGriff

    Yes, normally I would camelCase it, but it was just an example to show it can be done in C#. Normally I would call it reportingReason or similar as I would consider it too confusing to use the enum name as the name for an instance of that enum - it would be like saying

    string string = "string";

    and expecting no-one to laugh at you...

    I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in. Apathy Error: Don't bother striking any key.

    N Offline
    N Offline
    Nagy Vilmos
    wrote on last edited by
    #28

    Spam spam = Spam.WonderfulSpam;


    Panic, Chaos, Destruction. My work here is done. or "Drink. Get drunk. Fall over." - P O'H

    1 Reply Last reply
    0
    • N Nagy Vilmos

      Is it too late to add "... or so I have heard."?


      Panic, Chaos, Destruction. My work here is done. or "Drink. Get drunk. Fall over." - P O'H

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

      Oh yes! :laugh:

      I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in. Apathy Error: Don't bother striking any key.

      "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

      1 Reply Last reply
      0
      • R RenniePet

        Maybe I'm not explaining myself very well ... Here are some examples:

          const string CServiceName = "Merlinia Process Manager";
        
          private delegate void DProcessProcessHasStopped(IntPtr processHandle);
          private DProcessProcessHasStopped \_processProcessHasStopped;
        
          
          private void InitializeCrossThreadInvocation()
          {
             \_processProcessHasStopped = ProcessProcessHasStopped;
          }
        
          
          private void CT\_ProcessProcessHasStopped(IntPtr processHandle)
          {
             base.InvokeDelegate(\_processProcessHasStopped, processHandle);
          }
        

        This is part of a pattern in a class that supports cross-thread invocation of methods.

        public enum EProcessStatus
        {
        ProcStopped,
        ProcStarting, // Has been started, but has not reported "up and running"
        ProcRunning,
        ProcStopping // Has been signaled to stop, but not stopped yet
        }

          public EProcessStatus ProcessStatus;
        
        H Offline
        H Offline
        Henry Minute
        wrote on last edited by
        #30

        But, but, but .........

        public enum EProcessStatus
        {
        ProcStopped,
        ProcStarting, // Has been started, but has not reported "up and running"
        ProcRunning,
        ProcStopping // Has been signaled to stop, but not stopped yet
        }

          public EProcessStatus ProcessStatus { get; set; }
        

        surely?

        Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

        R 1 Reply Last reply
        0
        • N Nagy Vilmos

          TopCoder23 wrote:

          what do you call a char *?

          Earl Grey.


          Panic, Chaos, Destruction. My work here is done. or "Drink. Get drunk. Fall over." - P O'H

          G Offline
          G Offline
          Garth J Lancaster
          wrote on last edited by
          #31

          har har !!!! I like it ...

          N 1 Reply Last reply
          0
          • H Henry Minute

            Ha ha!

            Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

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

            Thank you Nelson!

            I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in. Apathy Error: Don't bother striking any key.

            "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

            1 Reply Last reply
            0
            • G Garth J Lancaster

              har har !!!! I like it ...

              N Offline
              N Offline
              Nagy Vilmos
              wrote on last edited by
              #33

              Milk? Sugar?


              Panic, Chaos, Destruction. My work here is done. or "Drink. Get drunk. Fall over." - P O'H

              G 1 Reply Last reply
              0
              • R RenniePet

                Beware all those who read the following, they are the irreverent ramblings of a heretic ... Religious beliefs are so tricky. For the true believer no alternatives can be possible. Their minds are closed. I was once a devout believer of Hungarian notation. Charles Simonyi was my guiding light. My strings were all szDecorated, and I was at peace with the world. But, as with all religions, there were those who would not accept the one true way. Hedonistic forces held sway at Microsoft, and .Net naming conventions repudiated Hungarian notation! I was thrown into confusion, and my world disintegrated around me! Had I been led astray? Were my beliefs really so faulty? All those years, for nothing? And then I noticed something incredibly suspect about the preachings of the anti-Hungarian notationalists. Despite their adamant claim that Hungarian notation was evil, they in reality espoused a corrupted form of Hungarian notation themselves! Yes, it is true, the anti-Hungarian notationalists are inconsistent! They call for the abolition of Hungarian notation, while preaching the following doctrine: - The names of interfaces must start with the letter I. - The names of types must start with the letter T. Why was this? How could they ask me to give up one faith for a new one that contradicted itself? And then one day my turmoil was resolved! In a moment of revelation the great nerd in the sky spoke to me: "Do not follow the preaching of others! Create your own religion, be true to yourself, and say to hell with the forces of conformity. It will be a rocky road, and you will be held in contempt, but you will discover an inner peace that not even Hungarian notation gave you." I call my new religion "one-garian notation". It can be considered to be a further development (or corruption, if you will) of the .Net naming conventions, where not just the names of interfaces and types have specific one-character prefixes, but the following as well: - The names of constants must start with the letter C. - The names of delegates must start with the letter D. - The names of enumerators must start with the letter E. That's it. One-garian notation (named because it is based on one-character prefixes) is the same as .Net naming conventions, plus the use of three additional one-character rules, for a total of

                G Offline
                G Offline
                Gary R Wheeler
                wrote on last edited by
                #34

                I've always despised Hungarian notation, because it breaks a basic tenet of object-oriented programming: hide the implementation. Encoding the variable type in the name binds you to a specific implementation. I've never seen a Hungarian-ophile who was sufficiently rigorous about refactoring when they changed the type of a variable to always change the name at the same time. You end up with a variable named iFixedSize and another ulFixedSize, they refer to the same thing, and are declared to be unsigned long's.

                Software Zen: delete this;
                Fold With Us![^]

                modified on Sunday, May 9, 2010 8:45 AM

                1 Reply Last reply
                0
                • H Henry Minute

                  But, but, but .........

                  public enum EProcessStatus
                  {
                  ProcStopped,
                  ProcStarting, // Has been started, but has not reported "up and running"
                  ProcRunning,
                  ProcStopping // Has been signaled to stop, but not stopped yet
                  }

                    public EProcessStatus ProcessStatus { get; set; }
                  

                  surely?

                  Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                  R Offline
                  R Offline
                  RenniePet
                  wrote on last edited by
                  #35

                  OK, but my point is that you can't say this:

                    public enum ProcessStatus
                    {
                       ProcStopped,
                       ProcStarting,  // Has been started, but has not reported "up and running"
                       ProcRunning,
                       ProcStopping   // Has been signaled to stop, but not stopped yet
                    }
                  
                  
                  
                    public ProcessStatus ProcessStatus { get; set; }
                  

                  That gives a compiler error.

                  L 1 Reply Last reply
                  0
                  • N Nagy Vilmos

                    Milk? Sugar?


                    Panic, Chaos, Destruction. My work here is done. or "Drink. Get drunk. Fall over." - P O'H

                    G Offline
                    G Offline
                    Garth J Lancaster
                    wrote on last edited by
                    #36

                    a drop of chateau moo (milk), pref low fat (ok, a purist would drink Earl Grey black I suspect) I never get the CC's , but made that connection [char -> Earl Grey] so quick I had to chuckle

                    1 Reply Last reply
                    0
                    • R RenniePet

                      Beware all those who read the following, they are the irreverent ramblings of a heretic ... Religious beliefs are so tricky. For the true believer no alternatives can be possible. Their minds are closed. I was once a devout believer of Hungarian notation. Charles Simonyi was my guiding light. My strings were all szDecorated, and I was at peace with the world. But, as with all religions, there were those who would not accept the one true way. Hedonistic forces held sway at Microsoft, and .Net naming conventions repudiated Hungarian notation! I was thrown into confusion, and my world disintegrated around me! Had I been led astray? Were my beliefs really so faulty? All those years, for nothing? And then I noticed something incredibly suspect about the preachings of the anti-Hungarian notationalists. Despite their adamant claim that Hungarian notation was evil, they in reality espoused a corrupted form of Hungarian notation themselves! Yes, it is true, the anti-Hungarian notationalists are inconsistent! They call for the abolition of Hungarian notation, while preaching the following doctrine: - The names of interfaces must start with the letter I. - The names of types must start with the letter T. Why was this? How could they ask me to give up one faith for a new one that contradicted itself? And then one day my turmoil was resolved! In a moment of revelation the great nerd in the sky spoke to me: "Do not follow the preaching of others! Create your own religion, be true to yourself, and say to hell with the forces of conformity. It will be a rocky road, and you will be held in contempt, but you will discover an inner peace that not even Hungarian notation gave you." I call my new religion "one-garian notation". It can be considered to be a further development (or corruption, if you will) of the .Net naming conventions, where not just the names of interfaces and types have specific one-character prefixes, but the following as well: - The names of constants must start with the letter C. - The names of delegates must start with the letter D. - The names of enumerators must start with the letter E. That's it. One-garian notation (named because it is based on one-character prefixes) is the same as .Net naming conventions, plus the use of three additional one-character rules, for a total of

                      B Offline
                      B Offline
                      Brady Kelly
                      wrote on last edited by
                      #37

                      RenniePet wrote:

                      - The names of types must start with the letter T.

                      WTF do you find that in .NET naming conventions?

                      R 1 Reply Last reply
                      0
                      • L Lost User

                        RenniePet wrote:

                        But, as with all religions, there were those who would not accept the one true way.

                        All religions claim the same; that you must seeketh the truth before you can find "the one true way". SysHungarion was a way of encoding additional type-related information into the variable-name. That way you could see that you was talking about a string, just by looking at the name of the variable. Then came along the people who create rules-of-thumbs, and every bloody component needed to have a prefix. Imagine discussions on whether the developmentgroup should adhere to "mnuExitMenu", "pmuExitMenu" and "cxmExitMenu". In all three cases, it doesn't add much besides costs. AppsHung was a blunt mistake. Still, it is recommended to add pre- and suffixes that give hints to the variables purpose, like Idx for an index, "cur" for the current item and so on. Stop being religious, and ask yourself what a good variable-name is. And yes, that idea will vary over time.

                        I are Troll :suss:

                        B Offline
                        B Offline
                        Brady Kelly
                        wrote on last edited by
                        #38

                        Eddy Vluggen wrote:

                        Still, it is recommended to add pre- and suffixes that give hints to the variables purpose

                        Suffixes FTW! int customerIndex;

                        1 Reply Last reply
                        0
                        • B Brady Kelly

                          RenniePet wrote:

                          - The names of types must start with the letter T.

                          WTF do you find that in .NET naming conventions?

                          R Offline
                          R Offline
                          RenniePet
                          wrote on last edited by
                          #39

                          Here: http://blogs.msdn.com/kcwalina/archive/2004/11/03/251722.aspx[^] But I should have said "generic types", not just types.

                          B 1 Reply Last reply
                          0
                          • R RenniePet

                            OK, but my point is that you can't say this:

                              public enum ProcessStatus
                              {
                                 ProcStopped,
                                 ProcStarting,  // Has been started, but has not reported "up and running"
                                 ProcRunning,
                                 ProcStopping   // Has been signaled to stop, but not stopped yet
                              }
                            
                            
                            
                              public ProcessStatus ProcessStatus { get; set; }
                            

                            That gives a compiler error.

                            L Offline
                            L Offline
                            Luc Pattyn
                            wrote on last edited by
                            #40

                            did you try a C# compiler? :confused:

                            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                            If you want my opinion or comment, ask in a forum or on my profile page; I will not participate in frackin' Q&A


                            R 1 Reply Last reply
                            0
                            • OriginalGriffO OriginalGriff

                              I too was a Hungarian convert. I too saw .NET and thought - is this not a step backwards? But then I relaxed a bit, and realized I do not look at listings much anymore - I use class diagrams; I use the IDE. I do not use paper. Both the class diagram and the IDE give you information on types, when you need them. I think the Hungarian has gone the way of the Arianism Apostasy, and am actually quite glad to see it go. At least you can read code now, without your eyes getting caught on a list of random seeming characters: "lpcivst" or similar in front of the words "UserNames". Mind you, I still use "tb" in front of text boxes, and "but" for buttons - but I never said I was consistent!

                              I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in. Apathy Error: Don't bother striking any key.

                              B Offline
                              B Offline
                              Brady Kelly
                              wrote on last edited by
                              #41

                              OriginalGriff wrote:

                              Mind you, I still use "tb" in front of text boxes, and "but" for buttons

                              I use the 'Text' and 'Button' suffixes for those two, other suffixes are similar, but all whole words.

                              1 Reply Last reply
                              0
                              • N Nagy Vilmos

                                OriginalGriff wrote:

                                So in Gealic: Pogue mahone!

                                Not even close. It's an inoquous phrase - literaly 'your mother' - but causes DEFCON2 offence. A bit like saying to a Cpian that they sound like CSS.


                                Panic, Chaos, Destruction. My work here is done. or "Drink. Get drunk. Fall over." - P O'H

                                B Offline
                                B Offline
                                Brady Kelly
                                wrote on last edited by
                                #42

                                Nagy Vilmos wrote:

                                It's an inoquous phrase - literaly 'your mother'

                                You should see what that same inoquous phrase will win you in SA as well, especially Cape Town.

                                OriginalGriffO 1 Reply Last reply
                                0
                                • L Luc Pattyn

                                  did you try a C# compiler? :confused:

                                  Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                                  If you want my opinion or comment, ask in a forum or on my profile page; I will not participate in frackin' Q&A


                                  R Offline
                                  R Offline
                                  RenniePet
                                  wrote on last edited by
                                  #43

                                  Uh, yeah. Visual Studio 2010. It says:

                                  Error 1 The type 'ConsoleApplication1.Program' already contains a definition for 'ProcessStatus'

                                  on the line that attempts to define a property with the same name as the enumerator.

                                  OriginalGriffO 1 Reply Last reply
                                  0
                                  • B Brady Kelly

                                    Nagy Vilmos wrote:

                                    It's an inoquous phrase - literaly 'your mother'

                                    You should see what that same inoquous phrase will win you in SA as well, especially Cape Town.

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

                                    Ventilation holes? About 9mm diameter? :laugh:

                                    I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in. Apathy Error: Don't bother striking any key.

                                    "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

                                    M 1 Reply Last reply
                                    0
                                    • R RenniePet

                                      Uh, yeah. Visual Studio 2010. It says:

                                      Error 1 The type 'ConsoleApplication1.Program' already contains a definition for 'ProcessStatus'

                                      on the line that attempts to define a property with the same name as the enumerator.

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

                                      Probably only if your enum is defined as part of your class (MyNamespace.MyClass.MyEnum) If it is defined as outside your class (MyNamespace.MyClass and MyNamespace.MyEnum) then it probably won't - certainly VS2008 doesn't. Which makes sense, because in the first case you are indeed trying to define two things (the enum and the instance) with identical fully qualified names, and the compiler cannot resolve the reference.

                                      I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in. Apathy Error: Don't bother striking any key.

                                      "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

                                      L R 2 Replies Last reply
                                      0
                                      • OriginalGriffO OriginalGriff

                                        Probably only if your enum is defined as part of your class (MyNamespace.MyClass.MyEnum) If it is defined as outside your class (MyNamespace.MyClass and MyNamespace.MyEnum) then it probably won't - certainly VS2008 doesn't. Which makes sense, because in the first case you are indeed trying to define two things (the enum and the instance) with identical fully qualified names, and the compiler cannot resolve the reference.

                                        I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in. Apathy Error: Don't bother striking any key.

                                        L Offline
                                        L Offline
                                        Luc Pattyn
                                        wrote on last edited by
                                        #46

                                        yep. you're right. :)

                                        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                                        If you want my opinion or comment, ask in a forum or on my profile page; I will not participate in frackin' Q&A


                                        1 Reply Last reply
                                        0
                                        • OriginalGriffO OriginalGriff

                                          Probably only if your enum is defined as part of your class (MyNamespace.MyClass.MyEnum) If it is defined as outside your class (MyNamespace.MyClass and MyNamespace.MyEnum) then it probably won't - certainly VS2008 doesn't. Which makes sense, because in the first case you are indeed trying to define two things (the enum and the instance) with identical fully qualified names, and the compiler cannot resolve the reference.

                                          I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in. Apathy Error: Don't bother striking any key.

                                          R Offline
                                          R Offline
                                          RenniePet
                                          wrote on last edited by
                                          #47

                                          That's true, but in many situations I prefer to define the enum in the class where it is to be used and made public. There is a longer discussion about this here: http://stackoverflow.com/questions/495051/c-naming-convention-for-enum-and-matching-property[^] If you look at that thread, the third-last post by someone named Hermann was the inspiration to my beginning heresy. :) C for constants and D for delegates came next, and my chances of redemption were gone. But I've resisted F for flag-style enumerators so far, although I'm not sure how much longer I can fight off the temptation. :(

                                          D 1 Reply 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