0

I'm planning to work with different libraries that use different conventions. One uses snake_case, another one uses camelCase. This leads to code that looks like I can't make up my mind:

Some_Result result = namespace1::this_cool_function() + Namespace2::thatOtherCoolFunction();

Is this just a suck it up and deal with it situation? Should I create a wrapper that makes everything use the same convention (and will hopefully get optimised out). Or is there a different way? Choosing a different library that matches my naming conventions (and that of the other libraries) is out of the question.

  • Does this answer your question? What is an Anti-Corruption layer, and how is it used? – gnat May 26 '20 at 7:56
  • @gnat Interesting read. However, it appears to me that an ACL is used with good reason, I'm not sure cosmetics fall into that category. – infinitezero May 26 '20 at 8:09
  • 3
    I would vote for "live with it". Of all the problems that face programmers, this one is pretty trivial. Adding a wrapper layer will only obfuscate things. – Simon B May 26 '20 at 9:24
4

You say that’s messy code. I might say it’s great because it draws a clear distinction between your own code base and the 3rd party code base. Good or bad isn’t at all clear cut in this situation.

But at the end of the day you’re dealing with C++. The style of C++ code bases differs tremendously, and that’s not going to change any time soon. Get used to it.

Don’t write a wrapper for what is ultimately a purely cosmetic issue. It takes effort to implement and maintain, and introduces new opportunities for bugs to creep in. Then it makes it harder for other people – who know the 3rd party library already – to contribute to your project. That’s not worth it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.