[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: help with naming convention
- From: Sean Conner <sean@...>
- Date: Thu, 13 Oct 2011 05:19:49 -0400
It was thus said that the Great Xavier Wang once stated:
> 2011/10/13 Patrick Mc(avery <email@example.com>:
> > I am planning on changing my business name for the 6th time. In a project I
> > did a while back, I used X as a separator and wrote code like this,
> > someXstupidXvar, I'm really bad at naming things!
> > In my next project I will be heavily using the Lua C API. I like their
> > naming conventions but I want my code to be easy to spot amongst theirs.
> > I figure that most non-trivial names have a commonly used part and one or
> > more uncommon parts.
> > I was thinking of truncating the common part at 3 or 4 characters and
> > capitalizing it, even if it did not sample the syllables of the full name.
> > So STA instead of STK for stack or ARR instead of ARY for array. I was then
> > thinking of separating with an underscore and then using lowercase and a
> > non-abbreviated name(s) for the less common parts.
> > so here are some fictitious examples
> > ARR_pop
> > ARR_rotate_left
> > STR_concatenate
> > STR_copy
> > NUM_to_hex
> > NUM_double
> > Does this sound logical? Any pitfalls I am setting myself up for? Is this
> > more of my naming insanity?
> > Thanks for reading-Patrick
> In my personal opinion, I think it's ugly :-(.
Here are the functions name I have for my version of a Lua network API (C
function, then Lua function name):
The following are available via the org.conman.net module:
I used "org.conman.net" to ensure that I don't overload any existing modules
named "net". I also have modules like "org.conman.table" that contain a few
table related routines I wrote that I found useful, as well as
"org.conman.string", "org.conman.debug" and so on.
The rest are all bound to a metatable to the userdata returned to Lua.
(that last function returns the length of the address, 4 for IPv4 addresses,
16 for IPv6)
I find that naming scheme makes it easy to map the C API to the Lua API.
-spc (I found I didn't care for the LuaSocket API, so I ended up writing