now, if you have families of flags, you should probably have a class
for each type all wrapped in one module (e.g.
"UserFlags::SecondaryRoadConditions.decode(x)" ) . imo, yes meta-
programming is cool, but it should not be considered unless it is
keeps the intention of the code obvious and is significantly cheaper
(in terms of time to implement and support).
best,
jim herber
Lari Kirby
--
Footsteps in the sands of time are not made by sitting down.
---
The greatest glory does not exist in never falling, but in rising every time we fall.
---
Mathematicians are lazy: they prove something once and then take it as given from then on. - Hal Hanes, Math Professor (paraphrased)
---
"Why program by hand in five days what you can spend five years of your life automating?" - Terence Parr, creator of ANTLR
----- Original message -----
From: "Ron Phillips" <RPhi...@engineer.co.summit.oh.us>
To: colum...@googlegroups.com
Date: Thu, 09 Aug 2007 13:25:01 -0400
Subject: [CRB] Advice and opinions?
Ok, I checked with my traffic buddies. "Gore" has several meanings, as you point out. It's 'bloody' awkward, no 'bull', but in traffic talk, the "gore" of a road is like a person's "taint," except it's a road -- tain't the expressway, tain't the exit. That triangle of grass is the 'gore' of the exit. Who knew?
Ron
>>> "Ken Barker" <ken.b...@gmail.com> 08/09/2007 1:11 PM >>>
Anyone else hoping that 'On Gore' means something different than expected? ;-)
nice discussion. first let me offer a link to some reference material.
http://www.dps.state.oh.us/CrashRequests/Common/CrashTTDoc.pdf
i personally find the two most fun things i do is acquiring new tools
and choosing the perfect tool for the job. it is the mark of a
craftsman. of course, you can always use a general purpose tool, if
that's all you have. in my wood shop, when i am cutting veneer i reach
for my veneer saw, even though the table saw or band saw would also
work, just not as well.
as i read all of the posts, i am reminded of the old saying, "when all
you have is a hammer, everything looks like a nail." so let me offer a
(likely unpopular...lol) opinion suggesting you put the ruby
sledge-hammer back in the tools box and take this opportunity to learn a
new specialty tool. and don't even think about reaching for the
swiss-army chainsaw a.k.a perl :) as an old timer in coding terms (25+
years) i have quite a large tools box--not bragging, i'm just old ;)
and, i encourage you to enlarge yours.
anyway, back to your problem. your are parsing data from lines of texts.
i doubt you will be getting little snippets of text hundreds of times
per day. you will likely want to bulk process the in-coming text data
in a single, simple, quick process. this begs to be processed as a
stream, of course. there are many tools to do this and many approaches
to building your parser. however, i think the key factor here is that
you will likely write this script, and then use it for long periods of
time. time enough to "forget" exactly how it works--perhaps you might
not even be the next person to modify it.
so, you need a tool that adds very little cruft around the job of
parsing and "decoding" your field data. in fact, the perfect tool will
help you to see the rules and definitions of of parsing (your grammar)
at-a-glance. this is where the general-purpose languages fall down.
that said, i will not tell you which tool you should pick, that's part
of the fun. but i will leave you with this small example to amplify my
point.
on page 6 of the PDF above, column 3 gives you the field lengths. using
that information, the following awk script will parse a tractape file in
to a tab separated values file. note i only used the first 10 fields
for example brevity i.e. laziness ;)
BEGIN { OFS = "\t"
FIELDWIDTHS = "11 10 5 2 2 1 1 2 5 1" }
{ print $1, $2, $3, $4, $5, $6, $7, $8, $9, $10 }
i doubt even Ruby can be more succinct then that! almost anyone with
minimal programming experience can quickly grasp that this 3 line script
will (on line 1) use tabs to separate values and (on line 2) split
fields at fixed intervals of 11 10 5 etc. obviously, the print
statement (on line 3) could be turned into a loop rather than explicitly
printing each field. though, i kind of like fact that you get a quick
field count from the print statement. moreover, if you wanted to wrap
some extra text around certain fields, it would be trivial even for a
first year programming student.
my point? that, using the right tool for the job makes the job
wonderfully simple and fun. okay, okay, this is a Ruby group, so why
not use Ruby...and i am all for it. just take this little script and
pop it into a system exec statement e.g.
system("cat myfile | awk 'BEGIN {...}'")
and viola!
my two cents...
-sandman
Thanks again, everyone.
Ron