Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
I will hate you

Dear C++ library writer,

  1. If your library forces me to use new all over, I will hate you.

  2. If your library has types with bogus values, I will hate you.

  3. If the documentation for your library gets the terminology of its own domain wrong, I will hate you.

  4. If I say "My God, it's full of stars!" when I see the function signatures in your library, I will hate you.

  5. If your library uses #define instead of const or inline, I will hate you.

  6. If your library has a base class of everything, I will hate you.

  7. If your library has singletons, I will hate you.

  8. If you think you can use a tool to automatically translate a library from Java, I will hate you.

  9. If the classes in your library have such clear responsibilities that you call them "managers", I will hate you.

  10. If your library does not play nice with the standard library, I will hate you.

  11. If functions in your library return error codes instead of throwing exceptions, I will hate you.

  12. If your library has public members that are designed to be used only from internal code, I will hate you.

  13. If your library makes use of the global namespace, I will hate you.

  14. If your library has types traits that don't play nice with SFINAE, I will hate you.

@coding-bunny

This comment has been minimized.

Copy link

@coding-bunny coding-bunny commented Oct 10, 2014

yay for promoting std::unique_ptr and std::shared_ptr!

@NikolaiAlexanderHimlan

This comment has been minimized.

Copy link

@NikolaiAlexanderHimlan NikolaiAlexanderHimlan commented Oct 10, 2014

There are 3 items on your list I am confused by and would like to understand better. First, why are #defines bad? Second, why are "managers" bad? Third, what do you mean by base class of everything?

@olafurw

This comment has been minimized.

Copy link

@olafurw olafurw commented Oct 10, 2014

12 should be higher on the list.

@rmaicle

This comment has been minimized.

Copy link

@rmaicle rmaicle commented Oct 10, 2014

Don't show him any C++ library in development or he will hate you :)

@superfunc

This comment has been minimized.

Copy link

@superfunc superfunc commented Oct 10, 2014

@Blastinburn const is typesafe and obeys scope.

@luxe

This comment has been minimized.

Copy link

@luxe luxe commented Oct 11, 2014

If you don't provide common use case examples

@cgikoray

This comment has been minimized.

Copy link

@cgikoray cgikoray commented Oct 11, 2014

Not everybody library has the benefit of using exceptions, especially performance critical code. Blanket statement such as that are usually not well-received.

@Florianjw

This comment has been minimized.

Copy link

@Florianjw Florianjw commented Oct 11, 2014

Performance is not an argument against exceptions, since they are faster then error-codes when not thrown (which should be almost all of the time); real-time behavior is. So: If the library is for controlling a plane or space-ship, yes, exceptions should be avoided.

Often when exceptions aren't used however, the reasons are clearly not as good. GUI-libraries for example should really use exceptions for their errors.

@kybernetyk

This comment has been minimized.

Copy link

@kybernetyk kybernetyk commented Oct 11, 2014

If functions in your library return error codes instead of throwing exceptions, I will hate you.

If your library throws I won't use it.

@miguelibero

This comment has been minimized.

Copy link

@miguelibero miguelibero commented Oct 13, 2014

the problem with managers is that they tend to not follow the S in SOLID

@SeAlgoAsoma

This comment has been minimized.

Copy link

@SeAlgoAsoma SeAlgoAsoma commented Oct 15, 2016

I don't even know what this is about, I'm just here because I hate markdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment