Comment On There has just got to be a better way ...

Have you ever finished doing something, and then thought to yourself, there has just got to be a better way to do this? Apparently, Mike's colleague has never had one of those moments: [expand full text]
« PrevPage 1Next »

re: There has just got to be a better way ...

2004-08-18 13:31 • by Matthew W. Jackson
I admire him for DIMing his variables. A lot of lesser programmers would leave Option Explicit turned off and never use those 22 DIM statements.

I could defend him and say this is more optimized than using arrays...he's avoding some heap allocation and manually unrolling some loops.

But seriously, what VB programmer would go to that much trouble for a negligable performance gain?

re: There has just got to be a better way ...

2004-08-18 13:32 • by Aarrgghh
Yeah, why didn't he unroll the loop? Jeez, some people...

re: There has just got to be a better way ...

2004-08-18 13:34 • by Aarrgghh
...the outer loop, I meant. Assume a reasonable maximum size for the table, copy/paste as needed, and throw in a lot of "if rs.EOF goto END" statements.

re: There has just got to be a better way ...

2004-08-18 13:39 • by Tim Cartwright

re: There has just got to be a better way ...

2004-08-18 13:56 • by TheF0o1
Of course, there has to be a better way. Actually, there are many better ways. The real question is: Is there a worse way?

The count variables really make say WTF. It looks like the programmer ran out of space on one line and figured they had to define a new variable for the next line.

For me, this gives a completely new meaning to obfuscated code. There's elegant code, which is just the right density. Then there's code so compressed as to be confusing. Now, there's code that appears to be far too diluted. This could be more evidence of being paid based on the number of lines of code.

re: There has just got to be a better way ...

2004-08-18 14:24 • by o2bjang
Why! These people need to understand that regular expressions are our friends

re: There has just got to be a better way ...

2004-08-18 14:32 • by RJ
Well this does make me curious about what the 'stripping' code looks like. Does it just use Replace(), or does it Left + Mid the string and then start all over again with InStr?

What's that you say about a cat? Oh. right. nevermind...

RE: There has just got to be a better way ...

2004-08-18 14:51 • by hassan.voyeau@gmail.com (Hassan Voyeau)
"I could defend him and say this is more optimized than using arrays..."

Array? Loop? all he needed was one count ...

re: There has just got to be a better way ...

2004-08-18 15:29 • by Sean
There are just some people who are afraid of Regular Expression. My boss complains when I use them, because he doesnt use them enough to remember the syntax of them......

re: There has just got to be a better way ...

2004-08-18 16:09 • by Matthew W. Jackson
Reminder:

As far as I know, VBA does not have any built-in support for Regular Expressions. I know you can use the scripting library, but there's no mention or documentation of it in the built-in VB help.

Assuming the person knew about regular expressions and didn't like them, I can understand that.

But personally, I'd rather have a semi-cryptic regular expression in a single line along with 20 lines explaining what it does than 20 lines of code that does the same without regular expressions.

I like the optimism

2004-08-18 16:31 • by David McNett
I like the optimism of including the two count variables in the aggregation lines. He's just gone to the trouble to set count = 0 but he optimistically includes it in the following line "count = count + test1 (et al)" in the hopes that maybe it's acquired a value magically.

re: There has just got to be a better way ...

2004-08-18 17:25 • by Tim Cartwright
http://royo.is-a-geek.com/iserializable/regulator/ really nice (AND FREE) regular epression syntax builder, plus it even has intellisense...

re: There has just got to be a better way ...

2004-08-18 22:08 • by Prakash
VB programming... easy to learn and misuse by any tom dick and harry.

re: There has just got to be a better way ...

2004-08-18 22:15 • by Tim Smith
I will admit my shame.

I know about regex. I don't use them enough. I really don't like them due to their highly cryptic nature.

IMHO, if you need a expression syntax builder, then there is something wrong with the solution.

But damn, they are powerful and when used properly are the right tool for the job.

re: There has just got to be a better way ...

2004-08-18 22:25 • by Steve Wallis
People's fear of regex is unwarranted.
Okay, I admit that back when I first saw them I was a little freaked out.
But the first time I needed to use them, I read the syntax guide for 10 minutes and went 'oh. ok. this is cool.'

Sure, it might take longer to sit there and code that one line, but damned if its not quicker than writing all that garbage above.


/bb|[^b]{2}/ - Shakespeare.

re: There has just got to be a better way ...

2004-08-18 23:44 • by Cain
Wow! This is great. The only thing I can fault him on is he hasnt accounted for "N/a" and "n/A".

re: There has just got to be a better way ...

2004-08-19 05:09 • by MrGenericCommentGetsInWithTheSpecRemarkAgain
"Do any of you bitches have the spec?"

re: There has just got to be a better way ...

2004-08-19 05:12 • by MrGenericCommentAlsoThinksRegExIsTheBestThingSince
RegEx's are awesome. Uncommented RegEx's are awesome and scary.

re: There has just got to be a better way ...

2004-08-19 05:14 • by MrGenericCommentHasNoticedThat
...the maxlength property of the name text box is greater than the actual number of characters you can post.

Last name was entered as:

MrGenericCommentAlsoThinksRegExIsTheBestThingSinceBroadlyEquallyDividedBakedFlourYeastEtcProducts

re: There has just got to be a better way ...

2004-08-19 06:36 • by RayS
OK, RegExes aside, why bother checking for the presence of +, -, n/A, etc?

Just do a Replace() without checking first - it does no harm if it's not found, and saves you time checking in the first place. Even without a RegEx you could shrink that function my 80%+.

What a goon.

re: There has just got to be a better way ...

2004-08-19 08:34 • by sloopy
I'm writing stuff like this before I leave my company

re: There has just got to be a better way ...

2004-08-19 10:36 • by Paul Shields
reminds me of political speaches: long-winded but doesn't say much

re: There has just got to be a better way ...

2004-08-19 11:24 • by Reagan
that code tastes like burning.

re: There has just got to be a better way ...

2004-08-19 12:39 • by John Carter
The jokes in the comments are sometimes too much. My sides hurt on some of the biting sarcasm.

Regexes from hell...

2004-08-19 18:25 • by foxyshadis
Regexes are only frightening because they were designed by the same kind of people who find the obfuscated C contest clear and an example of good coding styles. Perl's myriad extensions didn't help that at all.

Perl 6 will have completely overhauled and entirely new regex syntax, with almost no relationship to the current. It's actually understandable, if a bit more verbose, and I look forward to using it in the future. It should cut down on the quantity of regexes from hell out there.

Of course, this is besides the point in VB/ASP, with its dirt-simple like regexes. There isn't much excuse for manual string searching anymore, even performance.

Perl 6 scares me more and more...

2004-08-25 22:40 • by Distilled Software Hate
"Perl 6 will have completely overhauled and entirely new regex syntax, with almost no relationship to the current."

Sweet jumping jesus.
« PrevPage 1Next »

Add Comment