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