My irritation has been growing for some time that plenty of C++ is written in unmaintainable or insecure ways. My particular gripes at the moment are simple:
- Why can't people handle const properly? I would prefer that people use it restrictively until they have a need to do otherwise. It really does make code more readable, and if it's not done from the start, it's a nightmare to rectify later.
- Why do people use naked pointers? There's almost no situation (bar for arrays and possibly std:: containers) that you need to. Use references or std::auto_ptr. I know some think that pointers are clearer (self documenting at the point of a function call), but using a good editor all but negates this argument, and pointers cause all sorts of ambiguity about ownership. This is the root of most of the memory leaks I come across. Look up RAII, if you don't know what it is.
- Why do people still use char*? This is really a special case of my second point. It's not necessary, except for talking to legacy interfaces. Use std::string and std::istringstream for most of your needs. There are a _few_ acceptible exceptions to this rule, but not many.
- Why do people re-invent the wheel? At least use the standard containers. They're pretty portable these days, and they're generally better tested and optimised than something you'll grow at home. I'll let you off if you're programming an embedded system.
- Why do people pollute the global namespace? I see plenty of unnecessary global variables in my travels. Do people _want_ the pain of maintaining code using global variables? You may get away with laziness here in small projects, but if the program grows, you'll be sorry.
That's enough ranting for now. Back to work.