Comment On Damned IF You Do, Damned ELSE You Don't

We've established quite a few times that when it comes to highly paid consultants, there is no correlation between "code quality" and "hourly rate" (cost/appearance ratio is a completely different story). No less, it's still fun to point out that today's snippet (from DZ-Jay) comes from a highly-paid consultant. Apparently, this IF/ELSE/OTHERWISE logic was prevalent throughout much of the code DZ was maintaining ... [expand full text]
« PrevPage 1 | Page 2Next »

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 14:17 • by whoisfred
So, what is the WTF here?



Do you have a problem with IF ELSE statements?



Does it bother you that the IF part is the same as the ELSE part?



Obviously the code used to do something different depending on the
value of Request.QueryString("source_url").  The requirements
later dictated that the same operation be performed in both
circumstances.  The programmer, when making that change, didn't
want to cause any unwanted side-effects that might be caused by
removing the branch.  The sensible and logical thing to do, in
that case, is to simply give both branches the exact same code.

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 14:19 • by BradC
Just planning ahead, right? [8-|]

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 14:22 • by Matt B
35006 in reply to 35002
whoisfred:
The programmer, when making that change, didn't
want to cause any unwanted side-effects that might be caused by
removing the branch.  The sensible and logical thing to do, in
that case, is to simply give both branches the exact same code.




You are obviously joking or you are an idiot



If it's the former, this sense of humor really isn't that funny.

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 14:23 • by cdog
35007 in reply to 35002
Perhaps you could elaborate on "unwanted side-effects that might be
caused by removing the branch".  Try as I might, I can't figure
out what could go wrong by simply removing the IF ELSE.

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 14:26 • by cdog
35008 in reply to 35007
Or maybe my sarcasm detector is irreparably damaged from all the actual moronic posts... let's hope that's the case.

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 14:27 • by curtisk
Nice, you take the high road, I'll take the low road....hey we got to the same spot either way!  Jeeeez...

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 14:27 • by Mike R
35010 in reply to 35007
Anonymous:
Perhaps you could elaborate on "unwanted side-effects that might be
caused by removing the branch".  Try as I might, I can't figure
out what could go wrong by simply removing the IF ELSE.




Maybe there was a problem regarding a cache-flush that only occured
when an if-then-else statement were in that exact point. But, the more
likely case is it as paid by number of lines.

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 14:29 • by curtisk
35011 in reply to 35002
whoisfred:
So, what is the WTF here?



Do you have a problem with IF ELSE statements?



Does it bother you that the IF part is the same as the ELSE part?



Obviously the code used to do something different depending on the
value of Request.QueryString("source_url").  The requirements
later dictated that the same operation be performed in both
circumstances.  The programmer, when making that change, didn't
want to cause any unwanted side-effects that might be caused by
removing the branch.  The sensible and logical thing to do, in
that case, is to simply give both branches the exact same code.




LOL

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 14:32 • by Brad
35012 in reply to 35006
Matt B:
whoisfred:
The programmer, when making that change, didn't
want to cause any unwanted side-effects that might be caused by
removing the branch.  The sensible and logical thing to do, in
that case, is to simply give both branches the exact same code.




You are obviously joking or you are an idiot



If it's the former, this sense of humor really isn't that funny.




What Matt B said.  The only thing that could be causing a side effect is the Request.QueryString("source_url")
call.  If this is an issue, then the call should be made outside
the if clause and the branch should still be removed.  There is
absolutely no sense in  maintaining two copies of the same code
when one will do.



- B

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 14:35 • by OneFactor
35013 in reply to 35007

Wow.... I was struck speechless for at least a minute there.


Wonder if this consultant ever thought of nesting these beasts inside one another? [:^)]

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 14:44 • by whoisfred
35015 in reply to 35006
Anonymous:
whoisfred:
The programmer, when making that change, didn't
want to cause any unwanted side-effects that might be caused by
removing the branch.  The sensible and logical thing to do, in
that case, is to simply give both branches the exact same code.




You are obviously joking or you are an idiot



If it's the former, this sense of humor really isn't that funny.




So, basically you took time out to say one of two things to me:



A)  You are an idiot.



  -or-



B)  You aren't funny.



Why be so negative?



This is a place that people are supposed to come to make fun of others not each other!

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 14:46 • by cm5400
35016 in reply to 35010

Mike R:
Anonymous:
Perhaps you could elaborate on "unwanted side-effects that might be caused by removing the branch".  Try as I might, I can't figure out what could go wrong by simply removing the IF ELSE.


Maybe there was a problem regarding a cache-flush that only occured when an if-then-else statement were in that exact point. But, the more likely case is it as paid by number of lines.


Do programmers actually get paid by the line?  (cringe...Waits for flame thrower to hit)  I have never actually programmed outside of work before.  I can't see where that would be a good way to do business, on the other hand it could be very profitable...

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 14:51 • by Rick
35018 in reply to 35006
Anonymous:
whoisfred:
The programmer, when making that change, didn't
want to cause any unwanted side-effects that might be caused by
removing the branch.  The sensible and logical thing to do, in
that case, is to simply give both branches the exact same code.




You are obviously joking or you are an idiot



If it's the former, this sense of humor really isn't that funny.


I laughed.

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 15:10 • by whoisfred
35020 in reply to 35016
cm5400:

Do programmers actually get paid by the line?  (cringe...Waits
for flame thrower to hit)  I have never actually programmed
outside of work before.  I can't see where that would be a good
way to do business, on the other hand it could be very profitable...





It would be profitable for the programmer, but  not for the
employer.  For the 'by the line' approach to be anything near
useful for an employer, the employer would also have to do code reviews
to make sure the programmer isn't doing the kind of donkey doo we see
here.  But, if you are going to do code reviews, then you can just
pay based on merit according to the code reviews.



I doubt many people, (if any at all) have or do get paid by the
line.  I wouldn't be surprised if in the past employers used to
base an employees productivity by numbers of lines, but I would hope
that most employers have wised up by now and use better methods of
determing productivity and program quality.

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 15:16 • by Emmy
http://www.dba-oracle.com/dress_code.htm - Is this a joke? I don't know
anyone who would be willing to live by that dress code. And hello, "All
ear hair must be shaved"? Yikes.

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 15:18 • by rogthefrog

This is called Best Practices and eXtreme Programming, people: TEST EARLY (first if...) and TEST OFTEN (else block).

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 15:24 • by DZ-Jay
I submitted that WTF and I can tell you that it is based on real code I
have been given to maintain, and that the consultant in question was a "professional" VB coder paid by project not by lines of code (does anybody?).



Plus, this was production code, and the consultant no longer maintains
it, so I can asure you that it wasn't an attempt to avoid side-effects
while testing, but more likely what I call "Copy Paste Syndrome", or the (incredibly common) "DeMorgan Mutation Disorder",
where someone tries to refactor the logic of conditional branching in
an attempt to simplify it, and ends up with a disastrous monster that
just happens to branch as intended, mostly. :)



    -dZ.

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 15:25 • by Bustaz Kool
35024 in reply to 35015

whoisfred:
This is a place that people are supposed to come to make fun of others not each other!


You must be new to this planet...and when are the pancakes coming?

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 15:54 • by Craig Stuntz
35025 in reply to 35006
Anonymous:
You are obviously joking or you are an idiot


Actually, there's a third possibility: He wrote the code and was paid by the line.

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 16:01 • by Trigger
Donald K. Burleson

Man this dude looks like an Umpa-Lumpa!

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 16:03 • by Otto
35027 in reply to 35016
cm5400:

Do programmers actually get paid by the line?  (cringe...Waits for flame thrower to hit)  I have never actually programmed outside of work before.  I can't see where that would be a good way to do business, on the other hand it could be very profitable...



Heck yeah! I'd be coding myself up a Lexus!  [:D]

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 16:30 • by cm5400' Boss
35028 in reply to 35027
Well, now you can begin all over

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 16:37 • by pjabbott

Am I the only one who looks at "&verify=1" and gets an ominous feeling?  I hope that's not a flag put in the URL query string to perform some sort of security or input verification, because if it is, the user could theoretically replace it with "&verify=0" to do an end run around the measures in place. 


The query string will be visible by the user in their address bar since a response.redirect is being perfomed instead of a server.transfer.  Maybe I'm just paranoid.


 

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 16:48 • by tiro

Hah!  You think that's bad, try entire parallel methods!  It's sad, but I've seen it.  On a related note, is it physically possible to read this many books on Oracle much less write them?  And the wife?  With the minature horses


All in all, that leaves me more speechless than the actual WTF. 

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 16:54 • by ces
35032 in reply to 35022
Brilliant.

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 17:08 • by allanc
> People
can spot a cheap suit at 300 yards, and so can our clients.




I like how this implies that their clients are not people.

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 17:09 • by MikeB
35035 in reply to 35007

Anonymous:
Perhaps you could elaborate on "unwanted side-effects that might be caused by removing the branch".  Try as I might, I can't figure out what could go wrong by simply removing the IF ELSE.


The End if would get lonely. [:'(]

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 17:19 • by bobday
35036 in reply to 35020
whoisfred:
cm5400:

Do programmers actually get paid by the line?  (cringe...Waits
for flame thrower to hit)  I have never actually programmed
outside of work before.  I can't see where that would be a good
way to do business, on the other hand it could be very profitable...





It would be profitable for the programmer, but  not for the
employer.  For the 'by the line' approach to be anything near
useful for an employer, the employer would also have to do code reviews
to make sure the programmer isn't doing the kind of donkey doo we see
here.  But, if you are going to do code reviews, then you can just
pay based on merit according to the code reviews.



I doubt many people, (if any at all) have or do get paid by the
line.  I wouldn't be surprised if in the past employers used to
base an employees productivity by numbers of lines, but I would hope
that most employers have wised up by now and use better methods of
determing productivity and program quality.




If lawyers get paid by the hour and writers and reporters get paid by
the word, why couldn't programmers get paid by the line? 

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 17:47 • by Ayende Rahien
35037 in reply to 35007
Anonymous:
Perhaps you could elaborate on "unwanted side-effects that might be
caused by removing the branch".  Try as I might, I can't figure
out what could go wrong by simply removing the IF ELSE.




You aren't thinking deeply enough, this is a highly paid consulant that
obviously used complex multi threading in his code, in the case, the
evaluation of the IF undoubtly solved some syncronization problem.
Doing it any other way is Wrong ;)

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 17:59 • by pjabbott
35038 in reply to 35036

bobday:

If lawyers get paid by the hour and writers and reporters get paid by the word, why couldn't programmers get paid by the line? 


Imagine all of the loop unrolling that would take place...for performance optimization, of course [:P]


 

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 18:01 • by Anonymous
When I last saw the dress code, it wasn't nearly as elaborate, and had
no illustrations.  Back then, it looked almost legit.

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 18:05 • by wildclaw
35040 in reply to 35036
bobday:
If lawyers get paid by the hour and writers and reporters get paid by the word, why couldn't programmers get paid by the line?


And this statement is a good example of what is wrong with the world. People don't get paid for doing good work, they get paid for doing what looks like much work.

The best code I produce, usually take less amount of lines. The more lines the code have, the longer it takes to read it, the greater the chance that there is a bug hidden in it, and the greater the chance that there is duplicated code in it.





Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 18:20 • by Maurits
35041 in reply to 35040
Seconded.  A much more efficient model would be to pay programmers
by the number of times their code executed and did what it was supposed
to, minus the number of times their code executed and failed with an
error, minus five times the number of times their code executed and
failed silently (possibly staggering along long enough to corrupt data.)

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 19:07 • by Anonymous
35042 in reply to 35041

Can someone tell me WTF is up with the images on this page?  Are they supposed to be Don and the wife or what?


http://www.dba-oracle.com/art_fun_starwars_movie.htm

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 20:27 • by Matt B
35045 in reply to 35042
Anonymous:

Can someone tell me WTF is up with the images on this page?  Are they supposed to be Don and the wife or what?


http://www.dba-oracle.com/art_fun_starwars_movie.htm





Now that's irony - the guy with the rigid, "professional", "females can
NEVER wear anything but skirts" website posts photoshopped pictures of
himself on said website.  

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 20:32 • by dfinster
I refactor that to:



Response.Redirect strRedirect & "&verify=1&process=1"



In ASP the parens are optional
and mostly annoying.  Of course, my code (as the original WTF)
assumes that strRedirect already has some querystring, otherwise we
need to kill the leading "&".




Frankly, after spending a lot of time
refactoring ASP code, in a corporate IT shop, this is small
stuff.  Hardly worth talking about.




My favorite is when they take every
field from an Oracle database and append an empty tring to it so they
don't have to deal with NULL.




It ends up looking like:



var1 = rs("field1") & ""

var2 = rs("field2") & ""

var3 = rs("field3") & ""



I ran into a lot of that from my old job.



Re: Damned IF You Do, Damned ELSE You Don't

2005-05-25 23:32 • by cjs
There is the possibility that this could be the result of an automated
refactoring tool, though even then it's hard to think of a case where
this would result unless the automated refactoring tool is badly used.

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-26 02:38 • by Z
35048 in reply to 35040
wildclaw:

The best code I produce, usually take less amount of lines. The more
lines the code have, the longer it takes to read it, the greater the
chance that there is a bug hidden in it, and the greater the chance
that there is duplicated code in it.




As Edsger Dijkstra put it, one should not measure lines of code produced by a programmer, but lines of code spent.

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-26 04:04 • by Raw
35049 in reply to 35046

dfinster:
My favorite is when they take every field from an Oracle database and append an empty tring to it so they don't have to deal with NULL.

It ends up looking like:

var1 = rs("field1") & ""
var2 = rs("field2") & ""
var3 = rs("field3") & ""

I ran into a lot of that from my old job.


 


Actually, I've seen that and there is a reason. Due to some wierd bug in ADO, you sometimes get intermittent errors if you don't do that. For some reason, it is not the null values that screw things up, it is usually if there are several long strings in one record, and adding a nonsense empty string for some wierd reason fixes it. It is one of those really wierd Heisenbugs that don't appear when you singlestep through the code, just when it is run normally.


 


So, that sure is a WTF, but the WTF is in ADO.


 


Back to the WTF at hand. I suspect this is just test code put in before real data is available, and before that happened, the programmer moved on to other tasks and it was forgotten and never changed to the real values. Wrong, but something that happens to us all occasionally. He should have put a TODO-comment there...

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-26 04:13 • by Spidey
35050 in reply to 35042
Anyone else think that a dinosaur is
a little bit of an inappropriate logo for a forward thinking 'world
class' consulting company?




Oh, I get it, they're making a subtle reference to Oracle's relevance to the modern world........



Re: Damned IF You Do, Damned ELSE You Don't

2005-05-26 04:28 • by Drak
35051 in reply to 35029
pjabbott:

Am I the only one who looks at "&verify=1" and gets an ominous feeling?  I hope that's not a flag put in the URL query string to perform some sort of security or input verification, because if it is, the user could theoretically replace it with "&verify=0" to do an end run around the measures in place. 


The query string will be visible by the user in their address bar since a response.redirect is being perfomed instead of a server.transfer.  Maybe I'm just paranoid.


 



I get an ominous feeling too, because it should read "&verify=1". It says so somewhere in the URL RFC. Luckily browsers will eat "&verify=1" as if it was correct.


Drak

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-26 04:43 • by wtijsma
35052 in reply to 35016
cm5400:

Do programmers actually get paid by the line?  (cringe...Waits
for flame thrower to hit)  I have never actually programmed
outside of work before.  I can't see where that would be a good
way to do business, on the other hand it could be very profitable...





Ahh... Finally code generators are starting to pay off...



I think this would also explain the great pyramids of DIV

 

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-26 04:45 • by wtijsma
35053 in reply to 35052
Actually, it would explain most of the WTF's here, they're not bad
programmers, they're good consultants forced to write this type of code
by their evil management.

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-26 05:01 • by wtijsma
35054 in reply to 35048
Anonymous:
As Edsger Dijkstra put it, one should not
measure lines of code produced by a programmer, but lines of code
spent.




I get paid like that. That's why I don't use VB, because you can't put all code on 1 line.

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-26 06:28 • by DZ-Jay
35055 in reply to 35053
wtijsma:
Actually, it would explain most of the WTF's here, they're not bad
programmers, they're good consultants forced to write this type of code
by their evil management.




I most definitely beg to differ.  I've had to maintain code from
very incompetent consultants.  Some of them may have been
genuinely stupid, but most of them is just that they don't care enough
to do things the Right Way, or to even learn beyond code that merely
somehow works.



    -dZ.

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-26 06:31 • by DZ-Jay
35056 in reply to 35054
wtijsma:
Anonymous:
As Edsger Dijkstra put it, one should not
measure lines of code produced by a programmer, but lines of code
spent.




I get paid like that. That's why I don't use VB, because you can't put all code on 1 line.




I believe you can put it in one line.  I think you use colon ':'
to separate the commands, just like you would use a semi-colon ';' in
other languages.  Don't forget the "BASIC" in the "VisuaBasic" :)



    dZ.

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-26 07:47 • by Mike R
35059 in reply to 35055
DZ-Jay:
wtijsma:
Actually, it would explain most of the WTF's here, they're not bad
programmers, they're good consultants forced to write this type of code
by their evil management.




I most definitely beg to differ.  I've had to maintain code from
very incompetent consultants.  Some of them may have been
genuinely stupid, but most of them is just that they don't care enough
to do things the Right Way, or to even learn beyond code that merely
somehow works.



    -dZ.




OOh, Don't get me started on the incompetent consultant bandwagon. Case in point:



I used to work for a small company, and eventually received a better
offer in the games industry, naturally, like an idiot, I took it. The
company, trying to get the product I started to production hired a
highly paid consultant. I got sick of the gaming world, and came back
to the company I worked for. My code seemed to have morphed into some
tangle of WTFs. The product was never released and the company tanked.



Why? The consultant allowed his own arrogance seep into the code. Most
of the stuff I had working, and working well was completely hosed. It
took many months to get the program up and running again before the
company finally went under.



Re: Damned IF You Do, Damned ELSE You Don't

2005-05-26 08:03 • by wtijsma
35060 in reply to 35056
DZ-Jay:



I believe you can put it in one line.  I think you use colon ':'
to separate the commands, just like you would use a semi-colon ';' in
other languages.  Don't forget the "BASIC" in the "VisuaBasic" :)





You're right, I remember again... argh... it's all coming back to me... just thought I got rid of the VB bad trip flashbacks ;-)

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-26 08:52 • by Paul
35062 in reply to 35051

Only if you're Response.Write(...)ing it.  If you're Response.Redirect(...)ing, then it should be & and not &


Try it and see.

Re: Damned IF You Do, Damned ELSE You Don't

2005-05-26 09:13 • by DZ-Jay
35063 in reply to 35060
wtijsma:
DZ-Jay:



I believe you can put it in one line.  I think you use colon ':'
to separate the commands, just like you would use a semi-colon ';' in
other languages.  Don't forget the "BASIC" in the "VisuaBasic" :)





You're right, I remember again... argh... it's all coming back to me... just thought I got rid of the VB bad trip flashbacks ;-)




The sad thing is that ... er... I never got rid of them, and forever was cursed to retain that "knowledge". :(



    dZ.

« PrevPage 1 | Page 2Next »

Add Comment