[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: help with naming convention
- From: Dimiter 'malkia' Stanev <malkia@...>
- Date: Thu, 13 Oct 2011 16:48:06 -0700
A lot of the Glib libraries get written this way.
I'm using cairo graphics and pixman right now, and they all start with
cairo_, and pixman_.
Your example is kind of like SDL, it starts with SDL_, and SDL being
made of formerly game programmers, probably influenced by quake naming
CL_xx (for client side stuff), SV_xxx (for server side game logic),
G_xxx (for sharing), R_xxx (for rendering), etc.
Lastly you have glXxx, glutXxxx, glfwXxxx, clXxxx (OpenCL), etc.
But one thing that I've never quite got was C++ namespaces - mainly
because they are not "searchable" with simple mechanism. They are only
searchable if the code is "linked" e.g. knows about each other, and this
is usually only done after compiling step, or some very special
heuristic code browser.
Before coming with a name prefix, look at your functions, then just
google it - if you find related - then choose - either use the same
name, or if the library is too popular and orthogonal to yours, then it
might be used in the same linkage with yours, so you better use other name.
For example there was no need to come up with new "gl" extension for
OpenGL ES2 as normally you don't link OpenGL ES2 with OpenGL (rarely
it's need, but I had a case where that was needed).
Naming is the hardest simple thing one has to do :)
Not only your functions, but your children too!
On 10/13/2011 5:47 AM, Patrick Mc(avery wrote:
Thanks Dirk, Xavier, Sean, Peter and Petite Abeille
Based on feedback, I am thinking of a new scheme:
Drop the caps, they are indeed ugly and anything that is reminiscent of
Windows has to go
GPIB_talk -> gpib_talk
I like the idea of truncating over the randomness of attempts to
represent full words with less letters. I like the idea of prefixing
names from the library code they were called from(although my previous
examples did not obey this) but a single truncating value might not work.
What about this?(again fictitious names)
#include "kernel1"
k_dup
k_drop
#include "gpib4"
gpib_16_talk
The number that the include file ends in would match the truncation of
characters in it's variable name prefixes. I should also mention that I
am planning on writing a large number of tiny functions(perhaps 1000) so
this naming convention issue is quite import to keep order.
As Dirk had mentioned, I could rework a syntax highlighting file, in
this case to match prefixes before the underscore.
Thanks for the link too, P.A, I am guilty as charged on several of these!
--Patrick