Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
scroll top