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. General Programming
  3. C / C++ / MFC
  4. Class or object?

Class or object?

Scheduled Pinned Locked Moved C / C++ / MFC
question
11 Posts 8 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
    Vaclav_
    wrote on last edited by
    #1

    I understand that using Hungarian notation is nowadays pretty superfluous , however... Should I name class variable "cClass" as a class or "oClass" as an object. Just asking, do not flame me for splitting hair. Cheers Vaclav

    D M CPalliniC A S 6 Replies Last reply
    0
    • V Vaclav_

      I understand that using Hungarian notation is nowadays pretty superfluous , however... Should I name class variable "cClass" as a class or "oClass" as an object. Just asking, do not flame me for splitting hair. Cheers Vaclav

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Vaclav_Sal wrote:

      Should I name class variable "cClass" as a class or "oClass" as an object.

      It's completely up to you. What notation helps you to remember what it is?

      "One man's wage rise is another man's price increase." - Harold Wilson

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

      1 Reply Last reply
      0
      • V Vaclav_

        I understand that using Hungarian notation is nowadays pretty superfluous , however... Should I name class variable "cClass" as a class or "oClass" as an object. Just asking, do not flame me for splitting hair. Cheers Vaclav

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #3

        (hmmmm religious topic, my favorite) We do not use prefix or suffix (or hungarian notation) for our variable.

        class MyClass {};
        MyClass myClass;
        MyClass* myOtherClass;

        I'd rather be phishing!

        1 Reply Last reply
        0
        • V Vaclav_

          I understand that using Hungarian notation is nowadays pretty superfluous , however... Should I name class variable "cClass" as a class or "oClass" as an object. Just asking, do not flame me for splitting hair. Cheers Vaclav

          CPalliniC Online
          CPalliniC Online
          CPallini
          wrote on last edited by
          #4

          The IMPORTANT thing, mY Dear, is_choosing A conVention and USING it ConSiStenTly.

          In testa che avete, signor di Ceprano?

          A 1 Reply Last reply
          0
          • CPalliniC CPallini

            The IMPORTANT thing, mY Dear, is_choosing A conVention and USING it ConSiStenTly.

            A Offline
            A Offline
            Albert Holguin
            wrote on last edited by
            #5

            this.........+5

            1 Reply Last reply
            0
            • V Vaclav_

              I understand that using Hungarian notation is nowadays pretty superfluous , however... Should I name class variable "cClass" as a class or "oClass" as an object. Just asking, do not flame me for splitting hair. Cheers Vaclav

              A Offline
              A Offline
              Albert Holguin
              wrote on last edited by
              #6

              In Windows, you'll see "CClass" a lot (capital C as a prefix)... in Linux and a lot of standard libraries, you won't see any indication at all, for them enclosing things properly within namespaces is more important.

              1 Reply Last reply
              0
              • V Vaclav_

                I understand that using Hungarian notation is nowadays pretty superfluous , however... Should I name class variable "cClass" as a class or "oClass" as an object. Just asking, do not flame me for splitting hair. Cheers Vaclav

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

                If you intend to follow the object-oriented paradigm, then prefixing a variable name with 'o' for 'object' makes about as much sense as prefixing it with 'v' for 'variable'. You might still consider this sensible, to visibly discern them from type names, constants, and functions though. YMMV. As for 'c' (class) prefix, it's often used to distinguish type names from e. g. structs, integral types, enums, etc.. I used (and still use) this a lot, but the longer I think about it the less sense it appears to make: modern editors provide all the information you need by just hovering over the name in question, much more information in fact than you could ever sensibly pack into a prefix. The prefix therefore only carries valuable information if you tend to print out code and prefer analyzing code on paper. Again, not my preference, but YMMV.

                GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

                _ 1 Reply Last reply
                0
                • S Stefan_Lang

                  If you intend to follow the object-oriented paradigm, then prefixing a variable name with 'o' for 'object' makes about as much sense as prefixing it with 'v' for 'variable'. You might still consider this sensible, to visibly discern them from type names, constants, and functions though. YMMV. As for 'c' (class) prefix, it's often used to distinguish type names from e. g. structs, integral types, enums, etc.. I used (and still use) this a lot, but the longer I think about it the less sense it appears to make: modern editors provide all the information you need by just hovering over the name in question, much more information in fact than you could ever sensibly pack into a prefix. The prefix therefore only carries valuable information if you tend to print out code and prefer analyzing code on paper. Again, not my preference, but YMMV.

                  GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

                  _ Offline
                  _ Offline
                  _Flaviu
                  wrote on last edited by
                  #8

                  Ok, prefixes for generic objects (like 'o' for objects, or 'v' for variables) are bad notations, but prefixes for variables type make the code more readable, like a story e.g. 'str' for strings, 'n' for numbers, 'arr' for arrays, and so on ... and they are not so hard to type ...

                  S 1 Reply Last reply
                  0
                  • _ _Flaviu

                    Ok, prefixes for generic objects (like 'o' for objects, or 'v' for variables) are bad notations, but prefixes for variables type make the code more readable, like a story e.g. 'str' for strings, 'n' for numbers, 'arr' for arrays, and so on ... and they are not so hard to type ...

                    S Offline
                    S Offline
                    Stefan_Lang
                    wrote on last edited by
                    #9

                    You're referring to the incorrect use of hungarian notation. Let me point you to this great article about why it is wrong and how to use it correctly: http://www.joelonsoftware.com/articles/Wrong.html[^] :)

                    GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

                    _ 1 Reply Last reply
                    0
                    • S Stefan_Lang

                      You're referring to the incorrect use of hungarian notation. Let me point you to this great article about why it is wrong and how to use it correctly: http://www.joelonsoftware.com/articles/Wrong.html[^] :)

                      GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

                      _ Offline
                      _ Offline
                      _Flaviu
                      wrote on last edited by
                      #10

                      Interesting article ... so, the time has changed ?... :)

                      1 Reply Last reply
                      0
                      • V Vaclav_

                        I understand that using Hungarian notation is nowadays pretty superfluous , however... Should I name class variable "cClass" as a class or "oClass" as an object. Just asking, do not flame me for splitting hair. Cheers Vaclav

                        K Offline
                        K Offline
                        Kevin McFarlane
                        wrote on last edited by
                        #11

                        I don't use Hungarian these days but oClass seems to have been the more common style (especially in VB). In C++ it was also common not to use Hungarian with objects but just with simple types, integers, floats, etc. In the .NET world Hungarian is discouraged but there is still a widely-used concession to Hungarian with the names of UI controls. btnCustomer, etc., although really we should prefer customerButton.

                        Kevin

                        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