Saturday, 8 October 2011

Why Joel Spolsky is a numpty

Numpty being a technical term, of course. Have a look at this article:

http://www.joelonsoftware.com/articles/Wrong.html

The correct response to the encoded-non-encoded string problem is to create a separate type which mirrors the platform native string, but that cannot convert to a regular string, or only by a conversion operator which safely encodes it.

class unsafe_string {
    std::string mah_string;
public:
    //.. blah blah
    operator std::string() {
         return encode(mah_string);
    }
};

As such, instead of relying on the eye to review the code and make it safe, you can simply make the compiler do the work for you, which is a vastly superior alternative.

As for operator overloads, well, I'd just have to provide equivalent methods anyway- operator overloads are just syntactic sugar. Also, I don't know wtf IDE you use, but mine tells me the type on demand and will let me see it's declaration on demand as well.

No comments:

Post a Comment