3 ms·
And it's my experience that that is only a benefit to the person who wrote the code, and only for a short time. Generally, I prefer being able to read a line o
by secondcoming 6y ago
And it's my experience that that is only a benefit to the person who wrote the code, and only for a short time.
Generally, I prefer being able to read a line of code and understanding exactly what it does. If I need an IDE and have to repeatedly try to find the definition of something then, in my opinion, that's wasting my time.
C++'s 'auto' is really useful but it's over-used IMO. I think that there's a belief that if you're not using 'auto' everywhere then you're not writing 'modern' C++. Just becuase your code compiles doesn't necessarily mean it's correct.
- mehrdadn 6y ago+1 for auto being overused. I always felt I was shouting into the void (hah) by saying the same thing... it's nice to see someone else agrees.
- corty 6y agoCode that specifies types instead of using auto is, barring compiler bugs, usually less correct. The compiler knows better than you what the type really is.
- nicoburns 6y agoI find that types can reduce readability as well as enhance it. They add noise and make it harder to concentrate on the variable names which are often much more important than the types which are often (but certainly not always) obvious from context.
- secondcoming 6y agoInteresting point. I'd never have believed it myself, but find myself using acronyms instead of variable names when the type allows it. void foo(MyType mt, const MyOtherType& mot); It's the variable names that are the noise, types are everything. And no, it's not Hungarian notation either in case anyone suggests it! However, it maybe doesn't work that well with things like class member names. YMMV
- nicoburns 6y agoI guess it partly depends on how varied your types are. In some domains you can find yourself working with 10 variables that are all strings, or all floats/integers. At that point the type isn't that helpful for distinguishing which variable is which.
- secondcoming 6y agoI should have added that fairly liberal use of type aliases also helps. using B64String = std::string; B64String encode(const std::string& text); std::string decode(const B64String b64);