Inspired by this thread I was wondering whether fellow monks follow any conventions when choosing names for programmes and scripts.
I tend to use telling names for programmes and scripts which are operative, like buch.pl for a script which lets people order books; and names which rank from silly to plain non-sense to sometimes outright foul when writing wee test scripts whose life-span is expected to be anything below an hour.
Of course, sometimes these test scripts survive and actually get to be operative themselves, and as long as it's only me handling those scripts that is ok. But no (user|website visitor) should have to see a call for a script named shite.pl, hrmpf.cgi or any such.
And what happens, when someone else has to work with those scripts, say another webmaster, or even a job successor? Names like script1.pl, script2.pl are not exactly helpful to find out what the thing does. But then, sometimes names can be very obvious for the person creating the script, while not at all for others.
How do yous handle this?
--cs
There are nights when the wolves are silent and only the moon howls. - George Carlin
Re: What's in a Name?
by Abigail-II (Bishop) on May 29, 2002 at 10:17 UTC
|
First, I'd like to say something about the extension. There's a tendency
to have Perl programs end in '.pl'. Why is that? We type 'ls', 'mutt'
and 'netscape', not 'ls.exe', 'mutt.exe' or 'netscape.exe'. Why would
you want to type 'tool.pl' to execute the tool? That requires users to
remember in which language a tool is written. If you later replace the
tool by a better version, this time written in Python, will users be
pleased if they now have to type 'tool.py'?
I use '.pl' for files I'm still working on. But as soon as they escape
from their development directory, and are place in a directory that
might be in someones PATH, the '.pl' gets dropped.
Names should, IMO, be descriptive. "buch.pl" might be cute, and I can
guess that it's dealing with books, but not that it actually orders
books. If it orders books, I'd call it "orderbooks" or "order_books".
No ".pl" - the language in which it's written should not matter for
the results. I don't really care if a name is long. We don't live in
the early 70s anymore, nowadays we have shells with filename and
command completion, and we have aliases too.
Now, for scripts I only use once, or just to test things out, I usually
use 'x.pl', 'y.pl', 'z.pl', and other one letter combinations. And more
than 90% of the time, they will be placed in '/tmp'.
Abigail
| [reply] [Watch: Dir/Any] |
|
Let's talk about Windows first:
First if it's not a CGI, but a command line utility it is necessary to give those files an extension. The only other solution would be to force the users to use a Unix shell. That's be even harder on most of them.
Second ... the fact that you do not have to enter the .exe should lead to a question "Is it possible to set the system so that you do not have to type .pl?" And of course it is. You just have to add that extension to the list in PATHEXT system variable. Easy to do in a network login script or something, isn't it?
So then the script files do end with .pl, but everybody may call them without.
Then CGIs under Windows:
if you use Apache you do not need the extensions, if you use IIS you do. In either case it's not such a big problem to make a redirect there somewhere so that both addresses work.
For Unix:
yeah you are right that there the extensions are not needed. I find that way of handling files a bit crazy, but that's another point.
Jenda
| [reply] [Watch: Dir/Any] |
|
Many times I find using a pl extension convienent. I use probably about 90% of the time. For utils I don't use it. Then again most of my programs are run on my servers and not by end users.
-Lee
"To be civilized is to deny one's nature."
| [reply] [Watch: Dir/Any] |
|
I do agree with you as long as we're talking about user-called scripts. However, webservers tend to insist on extensions.
As far as why I'm using extensions for non-web scripts, I do admit that this is mainly a habit - I'm still mostly working on windoze.
--cs
There are nights when the wolves are silent and only the moon howls. - George Carlin
| [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] |
|
|
|
| [reply] [Watch: Dir/Any] |
OT: What's in a Name?
by jplindstrom (Monsignor) on May 29, 2002 at 20:32 UTC
|
I wrote a script called uptime_guard.sh (no Perl at all :( ) which is used to watch disk space, database segments, processes, etc. etc.
After six months we discovered that it, sometimes on some machines, crashed after being run for a measly three, four weeks. So I also made the script create another guard process, watching uptime_guard.sh . So who watches the watcher(1)?
Custos Custodio.
I think things like that is important.
/J
(1) That would be "Quis ipsos custos custodes?" in Latin.
| [reply] [Watch: Dir/Any] |
Re: What's in a Name?
by perrin (Chancellor) on May 29, 2002 at 15:22 UTC
|
Um, buch.pl? I would have named it "order_books", at least if it's a command-line script. I fully agree with Abigail's statement about leaving off the .pl.
For web-based applications, I don't need to follow silly Win32 conventions about file-naming because I use mod_perl. I have modules like MySite/Controller/OrderBooks.pm and tie them to URLs like /books/order/, or whatever the marketing folks like the look of. | [reply] [Watch: Dir/Any] |
Re: What's in a Name?
by FoxtrotUniform (Prior) on May 29, 2002 at 15:44 UTC
|
Naming conventions:
- At work, anything that gets called by machine gets a
.pl extension. (At home, the shebang line is identifier
enough -- and .pl collides with my Prolog stuff, anyhow.)
- Trivial test scripts are usually named foo,
bar, etc.
- I tend to follow Unix conventions when naming scripts:
mktmpl instead of make_template, for
instance. Fits better with my thinking patterns.
--
The hell with paco, vote for Erudil!
:wq
| [reply] [Watch: Dir/Any] |
|
|