Post #125,789
11/15/03 1:25:02 AM
|
Synchonicity
I'm data typing a general coordinate class - so I actually had to refresh my memory on the use of "union" - sometime the coordinates are named one thing, sometimes another - and I'm sitting here thinking - "I have the most fun doing this when I'm typing and naming things!"
(And Bob, shame on you for starting aVariable name with anIndefiniteArticle!)
-drl
|
Post #125,790
11/15/03 2:09:57 AM
|
When it's aNonymous, I usually do. Otherwise, nope.
|
Post #125,791
11/15/03 2:13:28 AM
|
I see
OK I can actually see the point of that.
But how is
aList
more descriptive than
List
All types are anonymous until you make an instance.
-drl
|
Post #125,800
11/15/03 6:10:44 AM
|
Not the point.
It's not that it's more descriptive, it's just that VERY often, the label without the leading 'a' is a keyword. "List" is a good example. And if it's not a keyword, it often ends up being a method name or something. Prefixing with 'a' or 'an' or (most often) 'each' for loops is a quick visual identifier that I'm working with something trivial, at least in scope. for project in projects:\n job = project.job just reads clearer IMO as: for eachProject in availableProjects:\n aJob = eachProject.job But it's only convention. I'm not preaching this or anything.
I was one of the original authors of VB, and *I* wouldn't use VB for a text processing program. :-) Michael Geary, on comp.lang.python
|
Post #126,154
11/17/03 5:23:53 PM
|
Here's a suggestion that will solve your problem
Instead of naming it aList how 'bout naming it something like nameList or recipeIngredientList ...in other words, tell us what kind of List it is as part of your name. I think doing something that like that on a regular basis should dissolve the writer's block youhave about naming things. (Although, I will admit, it is decidely non-Unix. Which, of course, is why I like it so much....)
jb4 "There are two ways for you to have lower Prescription-drug costs. One is you could hire Rush Limbaugh's housekeeper ... or you can elect me President." John Kerry
|
Post #126,155
11/17/03 5:30:07 PM
|
Re: Here's a suggestion that will solve your problem
Right!
I mean, does this happen?
// Ok, time for some coordinates! Don't know why, but I feel saucy, // and in the mood for coordinates!
SpaceCoords someCoordinates;
// ooh righteous! Now back to the problem...
No - you make things with a purpose, so name them according to the purpose.
Seriously, when I see code with prepended type identifiers and indefinite articles, I cringe.
-drl
|
Post #126,246
11/18/03 5:42:16 AM
|
No, no, I'm swinging *back* from that
..on the pendulum backswing. Been there, do that constantly. It's just not always necessary. Sometimes you _should_ write "for eachJob in currentSet". Anything more descriptive would just get in the way.
I was one of the original authors of VB, and *I* wouldn't use VB for a text processing program. :-) Michael Geary, on comp.lang.python
|
Post #126,690
11/19/03 11:14:20 AM
|
Sorry, No Sale
That would imply that you declared a variable called 'eachJob'. I'd love to see how you commented that... \n Job eachJob; // and I will describe this how?!?\n Even in this example, the Job you are working with has a specific putpose and use in the program. This purpose and use has a name, and if you enumerate that, the variable magically names itself in such a way that event the most casual observers (ar a complete idion...like me) can figure out what it does. YMMV
jb4 "There are two ways for you to have lower Prescription-drug costs. One is you could hire Rush Limbaugh's housekeeper ... or you can elect me President." John Kerry
|
Post #126,691
11/19/03 11:24:24 AM
|
That would imply that YOU don't use dynamic languages
In Perl:
for my $each_job (@job_list) { # Do something, like this... $each_job->start(); }
You will note that no declaration exists. And a comment about what you mean by a variable that is in scope for 2 lines which is clear in context is silly to the point of stupidity. (Why add the maintainance overhead if its purpose is that clear?)
Cheers, Ben
"good ideas and bad code build communities, the other three combinations do not" - [link|http://archives.real-time.com/pipermail/cocoon-devel/2000-October/003023.html|Stefano Mazzocchi]
|
Post #126,695
11/19/03 11:49:22 AM
|
What Ben said...
You need to get out more, Burns. C++ is a pretty cramped neighborhood... ;-)
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #126,698
11/19/03 11:53:02 AM
|
Even C++ allows defining in scope...
for (var job eachJob = .....
|
Post #126,717
11/19/03 3:12:33 PM
|
My two sense...
we usually had most logic than a simple ArrayList or Vector in our collection classes...
so: JobCollection allJobs; Job aJob; Job aProgammer; // Better still
Then: foreach (allJobs.begin(), allJobs.end(), <function call>);
(Or you could simply walk through them) for (allJobs::iterator i= allJobs.begin(); i != allJobs::iterator.end(); i++) { // DO something }
// The each aspect is implied - so it falls out.
|
Post #126,710
11/19/03 1:59:05 PM
|
Well,
I write in what I'm paid to write in. Right now that's C...with a migration to C++ in the offing.
Most of my work is in the embedded arena. The closest thing I have to a script language is the shell of whatever platform we're using for cross development (mostly Windows, which as we all know, doesn't have a shell; some work is going to happen on Linux [Hoo-RAY!], and I'm furiously learning bash, because csh sux!). Some talk of perl work; so I'll be availing myself of the collective's expertise soon enough.
Oh, yeah...and MAKE files...they're sorta a script....
We don' need no steenkin' Web services!
jb4 "There are two ways for you to have lower Prescription-drug costs. One is you could hire Rush Limbaugh's housekeeper ... or you can elect me President." John Kerry
|
Post #126,730
11/19/03 4:09:54 PM
|
Re: I write in what I get PAID to write in
Hm. I get paid to write in what I write in. Subtle difference. ;)
I truly appreciated the power of anonymity in dynamic languages today, when I wrote:
categories = {}.fromkeys(categories).keys()
which removes duplicate items from the sequence named 'categories'. The {} creates a new, anonymous dictionary, which is first populated with .fromkeys(), then immediately consumed by .keys(), which returns the list I want.
Of course, if I did this regularly, I would put it in a named function, like 'flatten' or 'dedupe' or something. But you get the idea.
I was one of the original authors of VB, and *I* wouldn't use VB for a text processing program. :-) Michael Geary, on comp.lang.python
|
Post #126,749
11/19/03 5:26:50 PM
|
You're clearly NOT a contractor, then...
jb4 "There are two ways for you to have lower Prescription-drug costs. One is you could hire Rush Limbaugh's housekeeper ... or you can elect me President." John Kerry
|
Post #126,747
11/19/03 5:14:44 PM
|
I don't.
Well, I do, but I also write in a lot of other things, too.
Because learning languages other than the ones I use at work gives me a new appreciation (or depreciation, for that matter ;-) for how they operate, and new insights into how to use them creatively to solve problems.
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #126,764
11/19/03 7:57:13 PM
|
must be nice to have real work
-drl
|
Post #126,793
11/19/03 11:47:21 PM
|
I'll bet it is too
FWIW
jobs do: [:each | each start].
"I believe that many of the systems we build today in Java would be better built in Smalltalk and Gemstone."
-- Martin Fowler, JAOO 2003
|