Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • Am I paranoid...: "Make your interfaces easy to use correctly, and hard to use incorrectly". I've tasted that particular principle when someone reported one of my static methods was, by mistake, used incorrectly. The error produced seemed unrelated, and it took multiple hours of an engineer to find the source. This "interface error" is in par with assigning an interface reference to another. So, yes, I want to avoid that kind of error. Also, in C++, the philosophy is to catch as much as possible at compile time, and the language gives us that power, so we go with it. Commented Apr 14, 2014 at 18:26
  • Best solution: I agree. . . Better solution: That's an awesome answer. I'll work on it... Now, about the Pure virtual classes: What's this? A C++ abstract interface? (class without state and only pure virtual methods?). How this "pure virtual class" protected me against slicing? (pure virtual methods will make instantiation not compile, but copy-assignment will, and move assignment will, too IIRC). Commented Apr 14, 2014 at 18:31
  • About the compiler: We agree, but our compilers is outside my scope of responsibility (not that it stops me from snarky comments... :-p ...). I won't disclose the details (I wish I could) but it is tied to internal reasons (like test suites) and external reasons (e.g. client linking with our libraries). In the end, changing the compiler version (or even patching it) is NOT a trivial operation. Let alone replace one broken compiler with a recent gcc. Commented Apr 14, 2014 at 18:38
  • @paercebal thanks for your comments; about pure virtual classes, you are right, it does not solve all your constraints (I will remove this part). I understand the "interface error" part and how catching errors at compile-time is useful: but you asked if you are paranoid, and I think the rational approach is to balance your need for static checks with the likeliness of the mistake happening. Good luck with the compiler thing :) Commented Apr 14, 2014 at 19:44
  • 1
    I'm not a fan of the macros, especially because the guidelines are targeted (also) at junior-men. Too often, I have seen people who were given such “handy” tools to apply them blindly and never understand what was actually going on. They come to believe that what the macro does must be the most complicated thing because their boss thought it would be too difficult for them to do themselves. And because the macro only exists in your company, they cannot even do a web search for it whereas for a documented guideline what member functions to declare and why, they could. Commented Oct 10, 2015 at 4:32