I’m working on a personal project that uses a few different libraries, such as GLFW, glm and Bullet. How are different naming conventions usually dealt with in this context?
Working with C++ I always used the same convention the standard library uses (all lowercase, underline as word separator, not ::getSize(), just ::size(), etc.) Personal preference aside, this works for me. glm uses a naming convention that is close to mine, but they use camelCase, even for types (there’s glm::vec3 for instance.) Bullet has things like btScalar, or btVector (prefixing everything with bt but the type has an uppercase first letter.) GLFW prefixes everything “GLFW” or “glfw”.
Usually, things like glm don’t bother me that much because the “glm::” prefix indicates clearly that it’s part of a library, but bullet has no namespace (I’m not sure but I believe it’s a C library.) My first instinct was to typedef the differences away, that is useless of course since I can’t rename method names (and good thing I didn’t, since there would be A LOT typedefs)
Should I just accept the differences? Maybe abstract everything behind another class? How do you usually deal with this?
3
Accept and use each library’s preferred naming preferences.
To do anything else would add a layer of abstraction between the true names and the ones you’ve picked to enforce your preferred style. That makes it somewhat of a nightmare to look up anything (including the library documentation for a method or function), unless the only real difference is capitalization (a distinction which really ought to be irrelevant anyway; just use the casing that the library has already established).
What’s worse than dealing with this is dealing with projects that have dealt with it in a cute way.
If I know something is supposed to be in a namespace, then at least I know that. I know it in all projects whenever I work with it. It might work great for you but anyone else who has used that library will be unnecessarily confused. And probably really annoyed.
My first instinct was to typedef the differences away
Don’t do this without a really, really good reason.