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.

3
  • Does this answer your question? What is an Anti-Corruption layer, and how is it used?
    – gnat
    Commented May 26, 2020 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. Commented May 26, 2020 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
    Commented May 26, 2020 at 9:24

1 Answer 1

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.

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