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. C++ Typedefs

C++ Typedefs

Scheduled Pinned Locked Moved C / C++ / MFC
c++questiondiscussion
7 Posts 7 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.
  • N Offline
    N Offline
    nitrous_007
    wrote on last edited by
    #1

    Does typedefs and a lot of use of typedefs make code complicated especially if code has to be used by a lot of people? I can understand cases where typedef can be useful for the person who created it and uses it but if the person revisits the code 5 years later or some other individual is reviewing the code, they have to constantly look up the typedefs. If there a couple of typedefs it might be ok but if the code is millions of lines and there are 1000 typedefs defined in various projects, does it not defeat the purpose of typedef? I would rather not use typedef's at all because of this and just deal with the pain of typing or using complete syntax. Any thoughts or revelations on this?

    L D J CPalliniC S 6 Replies Last reply
    0
    • N nitrous_007

      Does typedefs and a lot of use of typedefs make code complicated especially if code has to be used by a lot of people? I can understand cases where typedef can be useful for the person who created it and uses it but if the person revisits the code 5 years later or some other individual is reviewing the code, they have to constantly look up the typedefs. If there a couple of typedefs it might be ok but if the code is millions of lines and there are 1000 typedefs defined in various projects, does it not defeat the purpose of typedef? I would rather not use typedef's at all because of this and just deal with the pain of typing or using complete syntax. Any thoughts or revelations on this?

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

      As with most "shortcuts", you should only use them where they add value or improve readability.

      1 Reply Last reply
      0
      • N nitrous_007

        Does typedefs and a lot of use of typedefs make code complicated especially if code has to be used by a lot of people? I can understand cases where typedef can be useful for the person who created it and uses it but if the person revisits the code 5 years later or some other individual is reviewing the code, they have to constantly look up the typedefs. If there a couple of typedefs it might be ok but if the code is millions of lines and there are 1000 typedefs defined in various projects, does it not defeat the purpose of typedef? I would rather not use typedef's at all because of this and just deal with the pain of typing or using complete syntax. Any thoughts or revelations on this?

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

        nitrous_007 wrote:

        Does typedefs and a lot of use of typedefs make code complicated especially if code has to be used by a lot of people?

        How do they make code more complicated?

        nitrous_007 wrote:

        ...but if the person revisits the code 5 years later or some other individual is reviewing the code, they have to constantly look up the typedefs.

        Not if they were named/implemented correctly.

        nitrous_007 wrote:

        I would rather not use typedef's at all because of this and just deal with the pain of typing or using complete syntax.

        And what about that one place you forgot?

        "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
        • N nitrous_007

          Does typedefs and a lot of use of typedefs make code complicated especially if code has to be used by a lot of people? I can understand cases where typedef can be useful for the person who created it and uses it but if the person revisits the code 5 years later or some other individual is reviewing the code, they have to constantly look up the typedefs. If there a couple of typedefs it might be ok but if the code is millions of lines and there are 1000 typedefs defined in various projects, does it not defeat the purpose of typedef? I would rather not use typedef's at all because of this and just deal with the pain of typing or using complete syntax. Any thoughts or revelations on this?

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

          About the only place I use them is for function prototypes for lambdas. With intellisense and auto, my typing doesn't increase much and seeing the full type makes the code more clear for me.

          1 Reply Last reply
          0
          • N nitrous_007

            Does typedefs and a lot of use of typedefs make code complicated especially if code has to be used by a lot of people? I can understand cases where typedef can be useful for the person who created it and uses it but if the person revisits the code 5 years later or some other individual is reviewing the code, they have to constantly look up the typedefs. If there a couple of typedefs it might be ok but if the code is millions of lines and there are 1000 typedefs defined in various projects, does it not defeat the purpose of typedef? I would rather not use typedef's at all because of this and just deal with the pain of typing or using complete syntax. Any thoughts or revelations on this?

            CPalliniC Offline
            CPalliniC Offline
            CPallini
            wrote on last edited by
            #5

            Without typedefs (or using[^]) code could be a mess. Anyway nothing prevents messy code to take advantage of typedef to further mess up.

            In testa che avete, signor di Ceprano?

            1 Reply Last reply
            0
            • N nitrous_007

              Does typedefs and a lot of use of typedefs make code complicated especially if code has to be used by a lot of people? I can understand cases where typedef can be useful for the person who created it and uses it but if the person revisits the code 5 years later or some other individual is reviewing the code, they have to constantly look up the typedefs. If there a couple of typedefs it might be ok but if the code is millions of lines and there are 1000 typedefs defined in various projects, does it not defeat the purpose of typedef? I would rather not use typedef's at all because of this and just deal with the pain of typing or using complete syntax. Any thoughts or revelations on this?

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

              typedef is essential in metaprogramming, i. e. when you implement template classes that are supposed to fulfil certain criteria. This allows generic algorithms to specify certain dependant types in their implementation. (most notably, but not only, return types) Other than that, typedefs and using-declarations[^] can be used to imrpove readability. But these mechanisms should not be overused: I prefer to be able to read where a symbol is coming from rather than a name that may be a local symbol or not. That said, modern, language-sensitve text editors can show you what's behind a name very easily, maybe even in a tooltip. (and if yours doesn't, go look for a plugin that does)

              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
              • N nitrous_007

                Does typedefs and a lot of use of typedefs make code complicated especially if code has to be used by a lot of people? I can understand cases where typedef can be useful for the person who created it and uses it but if the person revisits the code 5 years later or some other individual is reviewing the code, they have to constantly look up the typedefs. If there a couple of typedefs it might be ok but if the code is millions of lines and there are 1000 typedefs defined in various projects, does it not defeat the purpose of typedef? I would rather not use typedef's at all because of this and just deal with the pain of typing or using complete syntax. Any thoughts or revelations on this?

                L Offline
                L Offline
                leon de boer
                wrote on last edited by
                #7

                I don't understand why you would need to look up a typedef constantly, if you want one you just declare it what does it matter what it is ... that is sort of the point to hide the base type and give a little more safety. Explain a situation where you are saying you need to look at what the type is and I am suggesting you are probably doing something wrong. You can size any type without knowing what it is by the sizeof function that is the usual error people make when they think they need to know what a typedef base type actually is. I don't care if you have thousands of types they make things easier not harder, so there is something going on with why you think otherwise.

                In vino veritas

                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