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. Other Discussions
  3. The Weird and The Wonderful
  4. If, for some weird reason, you _have_ to use Hungarian in .NET, at least use it properly

If, for some weird reason, you _have_ to use Hungarian in .NET, at least use it properly

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharpcom
31 Posts 12 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.
  • V Offline
    V Offline
    Vikram A Punathambekar
    wrote on last edited by
    #1

    Seen in production code

    int intTrStatusCnt = 0;
    long intMaxTrLogID = 0;
    long intMaxTrStatusID = 0;

    Cheers, Vıkram.


    Déjà moo - The feeling that you've seen this bull before. Join the CP group at NationStates. Password: byalmightybob

    S D C J R 6 Replies Last reply
    0
    • V Vikram A Punathambekar

      Seen in production code

      int intTrStatusCnt = 0;
      long intMaxTrLogID = 0;
      long intMaxTrStatusID = 0;

      Cheers, Vıkram.


      Déjà moo - The feeling that you've seen this bull before. Join the CP group at NationStates. Password: byalmightybob

      S Offline
      S Offline
      szukuro
      wrote on last edited by
      #2

      That's definitely not Hungarian believe me :P

      V C 2 Replies Last reply
      0
      • V Vikram A Punathambekar

        Seen in production code

        int intTrStatusCnt = 0;
        long intMaxTrLogID = 0;
        long intMaxTrStatusID = 0;

        Cheers, Vıkram.


        Déjà moo - The feeling that you've seen this bull before. Join the CP group at NationStates. Password: byalmightybob

        D Offline
        D Offline
        DavidNohejl
        wrote on last edited by
        #3

        Well, long *is* integer data type :)


        "Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe

        V 1 Reply Last reply
        0
        • D DavidNohejl

          Well, long *is* integer data type :)


          "Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe

          V Offline
          V Offline
          Vasudevan Deepak Kumar
          wrote on last edited by
          #4

          :)

          Vasudevan Deepak Kumar Personal Homepage Tech Gossips

          1 Reply Last reply
          0
          • S szukuro

            That's definitely not Hungarian believe me :P

            V Offline
            V Offline
            Vikram A Punathambekar
            wrote on last edited by
            #5

            szukuro wrote:

            That's definitely not Hungarian believe me

            ... hence the phrase 'use it properly'.

            Cheers, Vıkram.


            Déjà moo - The feeling that you've seen this bull before. Join the CP group at NationStates. Password: byalmightybob

            S 1 Reply Last reply
            0
            • V Vikram A Punathambekar

              szukuro wrote:

              That's definitely not Hungarian believe me

              ... hence the phrase 'use it properly'.

              Cheers, Vıkram.


              Déjà moo - The feeling that you've seen this bull before. Join the CP group at NationStates. Password: byalmightybob

              S Offline
              S Offline
              szukuro
              wrote on last edited by
              #6

              OK, I should've used the joke icon. If you take a look at my profile, I'm from Hungary. The joke was based upon the fact that Hungarian is not the same as Hungarian Notation.

              V S 2 Replies Last reply
              0
              • S szukuro

                That's definitely not Hungarian believe me :P

                C Offline
                C Offline
                CPallini
                wrote on last edited by
                #7

                And neither Italian, I can assure it! :-D

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

                1 Reply Last reply
                0
                • S szukuro

                  OK, I should've used the joke icon. If you take a look at my profile, I'm from Hungary. The joke was based upon the fact that Hungarian is not the same as Hungarian Notation.

                  V Offline
                  V Offline
                  Vikram A Punathambekar
                  wrote on last edited by
                  #8

                  Touché! :-D

                  Cheers, Vıkram.


                  Déjà moo - The feeling that you've seen this bull before. Join the CP group at NationStates. Password: byalmightybob

                  1 Reply Last reply
                  0
                  • V Vikram A Punathambekar

                    Seen in production code

                    int intTrStatusCnt = 0;
                    long intMaxTrLogID = 0;
                    long intMaxTrStatusID = 0;

                    Cheers, Vıkram.


                    Déjà moo - The feeling that you've seen this bull before. Join the CP group at NationStates. Password: byalmightybob

                    C Offline
                    C Offline
                    Chris Meech
                    wrote on last edited by
                    #9

                    Hey, give the guy/gal a break. At least the variables have been initialised. :)

                    Chris Meech I am Canadian. [heard in a local bar]

                    1 Reply Last reply
                    0
                    • V Vikram A Punathambekar

                      Seen in production code

                      int intTrStatusCnt = 0;
                      long intMaxTrLogID = 0;
                      long intMaxTrStatusID = 0;

                      Cheers, Vıkram.


                      Déjà moo - The feeling that you've seen this bull before. Join the CP group at NationStates. Password: byalmightybob

                      J Offline
                      J Offline
                      John R Shaw
                      wrote on last edited by
                      #10

                      Well, accept for the naming this is not a coding horror. If he was coding for Windows before Vista, he would even be correct. The reason being that with VC6, and any compiler that created 32 bit code, an int and a long where the same thing. I am not sure about a long but an int is supposed to be a machine word. In reality it depends on the compiler being used.

                      INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

                      P 1 Reply Last reply
                      0
                      • J John R Shaw

                        Well, accept for the naming this is not a coding horror. If he was coding for Windows before Vista, he would even be correct. The reason being that with VC6, and any compiler that created 32 bit code, an int and a long where the same thing. I am not sure about a long but an int is supposed to be a machine word. In reality it depends on the compiler being used.

                        INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

                        P Offline
                        P Offline
                        Pete OHanlon
                        wrote on last edited by
                        #11

                        But Hungarian notation used the l (or lng for the VBized version) to denote longs. Take this as an example, lpszMyText which stands for a Long Pointer to a String terminated by a Zero.

                        Deja View - the feeling that you've seen this post before.

                        J 1 Reply Last reply
                        0
                        • P Pete OHanlon

                          But Hungarian notation used the l (or lng for the VBized version) to denote longs. Take this as an example, lpszMyText which stands for a Long Pointer to a String terminated by a Zero.

                          Deja View - the feeling that you've seen this post before.

                          J Offline
                          J Offline
                          John R Shaw
                          wrote on last edited by
                          #12

                          Do you know what a long pointer is? I do. Hungarian notation has its uses, but it falls way short of what it was intended to do. In the case presented an int is probably 32 bit and an long is probably 32 bits, so coding wise it makes no difference until you start using a 64 bit compiler, in which case they will probably both be the same again.

                          INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

                          P A 2 Replies Last reply
                          0
                          • J John R Shaw

                            Do you know what a long pointer is? I do. Hungarian notation has its uses, but it falls way short of what it was intended to do. In the case presented an int is probably 32 bit and an long is probably 32 bits, so coding wise it makes no difference until you start using a 64 bit compiler, in which case they will probably both be the same again.

                            INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

                            P Offline
                            P Offline
                            Pete OHanlon
                            wrote on last edited by
                            #13

                            John R. Shaw wrote:

                            Do you know what a long pointer is? I do.

                            So do I (having a C/C++ background here). However, it is worth noting that there is a difference in the maximum/minimum allowed values between an int and a long. Try this in C#

                            Console.WriteLine(int.MaxValue.ToString());
                            Console.WriteLine(long.MaxValue.ToString());
                            

                            So, look at the code again and tell me - do you think that an int and a long can be treated the same here?

                            Deja View - the feeling that you've seen this post before.

                            J 1 Reply Last reply
                            0
                            • V Vikram A Punathambekar

                              Seen in production code

                              int intTrStatusCnt = 0;
                              long intMaxTrLogID = 0;
                              long intMaxTrStatusID = 0;

                              Cheers, Vıkram.


                              Déjà moo - The feeling that you've seen this bull before. Join the CP group at NationStates. Password: byalmightybob

                              R Offline
                              R Offline
                              Rob Grainger
                              wrote on last edited by
                              #14

                              A fragment found indicating a similar naming blunder encountered in our code... szCallerName.GetBuffer(0) :wtf:

                              1 Reply Last reply
                              0
                              • P Pete OHanlon

                                John R. Shaw wrote:

                                Do you know what a long pointer is? I do.

                                So do I (having a C/C++ background here). However, it is worth noting that there is a difference in the maximum/minimum allowed values between an int and a long. Try this in C#

                                Console.WriteLine(int.MaxValue.ToString());
                                Console.WriteLine(long.MaxValue.ToString());
                                

                                So, look at the code again and tell me - do you think that an int and a long can be treated the same here?

                                Deja View - the feeling that you've seen this post before.

                                J Offline
                                J Offline
                                John R Shaw
                                wrote on last edited by
                                #15

                                LOL! Sorry I tend not to notice the ‘.Net’ reference when looking at code that appears to be C or C++. Try that same logic in C or C++ and you will see it does not apply. When computers used 16 bit words an ‘int’ was supposed to be 16 bits as per language specifications (but actually it depended on the compiler). When they changed to 32 bit words (size of register) and new compilers came out, then ‘int’ became 32 bits per language specifications, which made it the same as a long. I do not know what artificial limits C# uses, but C and C++ uses register size and the compiler vendor sets the limits according to the standard. Any code you develop should be archived along with a copy of the compiler (environment) and the associated libraries, so that it can be recreated without having to modify it.

                                INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

                                P R 2 Replies Last reply
                                0
                                • J John R Shaw

                                  Do you know what a long pointer is? I do. Hungarian notation has its uses, but it falls way short of what it was intended to do. In the case presented an int is probably 32 bit and an long is probably 32 bits, so coding wise it makes no difference until you start using a 64 bit compiler, in which case they will probably both be the same again.

                                  INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

                                  A Offline
                                  A Offline
                                  Arun Immanuel
                                  wrote on last edited by
                                  #16

                                  John R. Shaw wrote:

                                  Do you know what a long pointer is? I do.

                                  long pointers are used to access memory that is located in the other segment(intersegment). Am I right?

                                  Regards, Arun Kumar.A

                                  J 1 Reply Last reply
                                  0
                                  • J John R Shaw

                                    LOL! Sorry I tend not to notice the ‘.Net’ reference when looking at code that appears to be C or C++. Try that same logic in C or C++ and you will see it does not apply. When computers used 16 bit words an ‘int’ was supposed to be 16 bits as per language specifications (but actually it depended on the compiler). When they changed to 32 bit words (size of register) and new compilers came out, then ‘int’ became 32 bits per language specifications, which made it the same as a long. I do not know what artificial limits C# uses, but C and C++ uses register size and the compiler vendor sets the limits according to the standard. Any code you develop should be archived along with a copy of the compiler (environment) and the associated libraries, so that it can be recreated without having to modify it.

                                    INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

                                    P Offline
                                    P Offline
                                    Pete OHanlon
                                    wrote on last edited by
                                    #17

                                    John R. Shaw wrote:

                                    Try that same logic in C or C++ and you will see it does not apply.

                                    I know - this caught me out a few times when I first moved over to .NET. I must admit that it really bugged me - especially when attempting to convert values. .NET standardised on int being Int32 and long being Int64.

                                    Deja View - the feeling that you've seen this post before.

                                    J 1 Reply Last reply
                                    0
                                    • P Pete OHanlon

                                      John R. Shaw wrote:

                                      Try that same logic in C or C++ and you will see it does not apply.

                                      I know - this caught me out a few times when I first moved over to .NET. I must admit that it really bugged me - especially when attempting to convert values. .NET standardised on int being Int32 and long being Int64.

                                      Deja View - the feeling that you've seen this post before.

                                      J Offline
                                      J Offline
                                      John R Shaw
                                      wrote on last edited by
                                      #18

                                      What really bugs me some times is that even though the C and C++ languages are standardized the size of the types are not. That is even the size of ‘char’ is not guaranteed to be a byte, at least that is what Bjarne Stroustrup says and he should know.

                                      INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

                                      P R 2 Replies Last reply
                                      0
                                      • A Arun Immanuel

                                        John R. Shaw wrote:

                                        Do you know what a long pointer is? I do.

                                        long pointers are used to access memory that is located in the other segment(intersegment). Am I right?

                                        Regards, Arun Kumar.A

                                        J Offline
                                        J Offline
                                        John R Shaw
                                        wrote on last edited by
                                        #19

                                        Actually no! Long pointers are not used any more and where used to overcome the limitations of PC memory access. The PC was limited to accessing only 64k, minus a few bytes for the systems use, so that was the max you could allocate with standard C (malloc). A normal pointer was only 16 bits, and a long pointer was a 32 bit pointer which required the compiler to generate code that allowed you to access more that 64k. Microsoft had the keyword ‘_far’ which told the compiler to make the pointer 32 bits instead of 16 bits and generate the required code. When Windows 95 came along and VC6 came out the ‘_far’ keyword was no longer supported, because it was not longer needed. All the ‘lp’ references in the code no longer mattered because all the pointers where now the same size, but if your previous code used the macro definitions like ‘LPSTR’ then it would still compile without error because the macros had been changed. If you had used the keyword ‘_far’ in any of your code, then you had to go in and remove it so you could compile the same code on the new compiler. That is pretty much it, ‘lp’ means ‘p’ now days.

                                        INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

                                        A 1 Reply Last reply
                                        0
                                        • J John R Shaw

                                          Actually no! Long pointers are not used any more and where used to overcome the limitations of PC memory access. The PC was limited to accessing only 64k, minus a few bytes for the systems use, so that was the max you could allocate with standard C (malloc). A normal pointer was only 16 bits, and a long pointer was a 32 bit pointer which required the compiler to generate code that allowed you to access more that 64k. Microsoft had the keyword ‘_far’ which told the compiler to make the pointer 32 bits instead of 16 bits and generate the required code. When Windows 95 came along and VC6 came out the ‘_far’ keyword was no longer supported, because it was not longer needed. All the ‘lp’ references in the code no longer mattered because all the pointers where now the same size, but if your previous code used the macro definitions like ‘LPSTR’ then it would still compile without error because the macros had been changed. If you had used the keyword ‘_far’ in any of your code, then you had to go in and remove it so you could compile the same code on the new compiler. That is pretty much it, ‘lp’ means ‘p’ now days.

                                          INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

                                          A Offline
                                          A Offline
                                          Arun Immanuel
                                          wrote on last edited by
                                          #20

                                          Thank you very much for your reply. But, in C Language, how to access the memory 0xb8000000 which is the memory address for VDU. Similarly , how to execute the POST function located at 0xffff000 without far pointer?

                                          Regards, Arun Kumar.A

                                          J 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