[OFFTOPIC] Naming convention for programs

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[OFFTOPIC] Naming convention for programs

Gerardo Santana Gómez Garrido
We're writing a set of tools at work and I'm thinking of establishing
a naming convention to enforce, before we get more programs deployed.

I was thinking of verb-subject, or verb_subject, or viceversa.

As always, I looked at OpenBSD for inspiration, and found

pkg_*
ssh-*
rpc.*

where the prefix is actually a sort of name space. And

user*
group*
skey*

no separator between subject and verb.

Based on your experiences, and ignoring for a moment the "historical"
reason, which naming convention would you use and why.

--
Gerardo Santana

Reply | Threaded
Open this post in threaded view
|

Re: [OFFTOPIC] Naming convention for programs

Douglas A. Tutty
On Fri, Mar 07, 2008 at 03:29:00PM -0600, Gerardo Santana G?mez Garrido wrote:
> We're writing a set of tools at work and I'm thinking of establishing
> a naming convention to enforce, before we get more programs deployed.
>
> I was thinking of verb-subject, or verb_subject, or viceversa.
>
> As always, I looked at OpenBSD for inspiration, and found
>
> pkg_*

requries a shift, slows typing

> ssh-*

no shift, slows only by extra char

> rpc.*

"." marks "extensions" to file names for some people (programs?) and I
wouldn't use this.

>
> where the prefix is actually a sort of name space. And
>
> user*
> group*
> skey*
>

No extra marker character.  Doesn't slow down typing but depending on
how the two halves of the names go together it could be confusing.

I would also see how apropos is affected by the choice.  Eg, if a user
can't remember which pkg_ command they want, they can apropos for "pkg_"
but if there is no "_", then apropos "pkg" may give extraneous results.

Doug.


> no separator between subject and verb.
>
> Based on your experiences, and ignoring for a moment the "historical"
> reason, which naming convention would you use and why.

Reply | Threaded
Open this post in threaded view
|

Re: [OFFTOPIC] Naming convention for programs

Matthew Szudzik
In reply to this post by Gerardo Santana Gómez Garrido
> I was thinking of verb-subject, or verb_subject, or viceversa.

If you are writing a family of related programs, then the word that they
have in common should be first.  For example, in OpenBSD there are

 mount_cd9660
 mount_ffs
 mount_msdos

and so on.  The fact that these programs perform related operations is
immediately apparent, and it is easy to find all of the related programs
simply by typing

 mount_

followed by TAB on the command-line.

Note that the word that is common could be a verb or a subject.
Although it is a verb in the case of "mount", it is a subject in the
case of "pkg":

 pkg_add
 pkg_create
 pkg_delete
 pkg_merge

> no separator between subject and verb.

Historically, "no separator" seems to win.  The best example is the
World Wide Web.  When it started in the 1990's, there were a plethora of
hyphen-separated URLs, but over time they have disappeared and been
replaced with no separator.

Mathematicians (who have dealt with this issue for centuries) also
prefer no separator:  "sinh" for "sine hyperbolic", "ln" for "logarithm
natural", "arcsin" for "arc sine", and "arcsinh" for "arc sine
hyperbolic".

The oldest and most-used Unix commands also follow this convention:
"lpq", "lpr", "lprm", "whereis", "mkdir", and so on.

Reply | Threaded
Open this post in threaded view
|

Re: [OFFTOPIC] Naming convention for programs

Gerardo Santana Gómez Garrido
Thank you guys for your ideas. I'll give them a second thought before deciding.

Regards,

--
Gerardo Santana