Since c ++ does not have an established agreement on the naming of various entities, each chooses his own method. However, you should always use the same naming convention throughout the project.

However, my question is this: if I write code that I’ll have to support not only me, what about the plug-in libraries? If I connect, for example, box2d , in which classes start with the prefix b2 , and methods are all capitalized, while I prefer java style — classes with big, methods with small, then how to be?

If this is a game engine, and I want the physics classes to be not internal, but visible to the user? Is this a bad tone - to use in the library project with other naming conventions. And how then to be? Use typedef ? And how then to be with functions?

What do you think about this? What do you do in such cases?

  • 3
    As O. Bender said, taking a cucumber from Panikovsky - "Do not make food a cult!" Everything is good in moderation, and to make a cult from naming up to renaming third-party libraries - in my opinion, brute force. IMHO, of course ("I have an opinion - you fucking challenge!" :)) - Harry
  • And of course, to abandon the library, because it has another naming convention, also a little overkill. - HolyBlackCat
  • @Harry yep you're right Just sometimes the idealist mode is turned on, and the mixes of various naming methods in one project begin to cut the eyes) - selya
  • If they do not answer here and close the question, try to ask Software Engineering . Thank. - Sasha Chernykh

1 answer 1

sarcask mode You cannot have problems with naming methods in c ++ :) there are no methods in c ++ :) sarcasm mode is off

When there is a problem of naming at the junction of two projects (or a library and a project), then no one bothers to write another layer of abstraction that will hide all inconvenient things, including names.

But if you want the user to give internal names - then this in itself is a problem. Give only your wrappers. If in the future, remits with box2d do something terrible (for example, they decide to remove some function or change the function signature), then your code will not break - you just need to finish the wrapper. If the user is given freedom, he will need to redo a lot of code.

  • Wrappers - the very first thing that comes to mind is yes. But to write them so lazy ... But my inner perfectionist decided that I would do it anyway. As for the methods and functions - someone identifies these concepts, someone considers different. Personally, I think the function is something more mathematical. Something that with unchanged input data will return the same answer. And the methods - everything else. - selya
  • Find out what pure function is . - KoVadim
  • I know very well what it is. But there is no point arguing about the not quite unambiguous terms "function" and "method", especially since the question was not about) I will not mark the answer yet, maybe someone else will write something interesting - selya
  • read Harry's comment again ... Personally, I can only say this - AR Hovsepyan
  • 2
    I remembered - all programmers have three problems - inventing names and an error by one. - KoVadim