Comment On Real Consultants Don't Use Loops

Loops. They're so ... well ... loopular. I mean, come on, do we really need them? Do we? If you think about it, they're nothing but crutches for the weak. Kinda like case statements or switch blocks. No, us highly-paid consultants don't need any of that. In fact, here's a perfect example of how to write PL/SQL. It's from the "professional services" division of a company that shall remain nameless. Jeff Atwood knows what good code is like. [expand full text]
« PrevPage 1 | Page 2Next »

Re: Real Consultants Don't Use Loops

2005-02-09 13:57 • by Kermos

i'm at...a loss of words to describe this....


this is such a genious piece of work. And to think, I've used loops all these years. How could I have possibly been so wrong!

Re: Real Consultants Don't Use Loops

2005-02-09 13:57 • by stewie
Wow. It takes dedication to craft a WTF like that. Coincidentally,
there was a posting on the CORBA newsgroup today which looks like was
written by the same guy.

Re: Real Consultants Don't Use Loops

2005-02-09 14:20 • by icelava
I'd hate to see the bill if the software needed to process 100 places. [6]

Re: Real Consultants Don't Use Loops

2005-02-09 14:27 • by
Wow this guy probably makes a bundle when they ask him for a 9th string. Maybe he's not so dumb. I can't imagine you could convince anyone else to maintain this code, so he's got job security too.

Re: Real Consultants Don't Use Loops

2005-02-09 14:42 • by DaveHumphrey
I'm just wondering what exactly it does. I guess comments weren't needed since its purpose is obvious...to someone anyways. I'm also wondering if they omitted the seventhplace check at the beginning on purpose or not.

Re: Real Consultants Don't Use Loops

2005-02-09 14:51 • by skicow

Another example of a consultant getting paid by the number of lines of code.


Good Christ that's a horrible piece of code....all those 'If' statements that have to be executed even if there is only one value passed.  And am I crazy (I don't know that much about PL/SQL ) but is he passing in a bunch of parameters delimited by the pipe character?


[:|]

Re: Real Consultants Don't Use Loops

2005-02-09 15:09 • by Kermos
29346 in reply to 29342

:
Wow this guy probably makes a bundle when they ask him for a 9th string. Maybe he's not so dumb. I can't imagine you could convince anyone else to maintain this code, so he's got job security too.


It'd be job insecurity if that guy was working for me. I'd give someone like that 2 choices:


1 - Do it right
2 - There's the door, have a nice day.

Re: Real Consultants Don't Use Loops

2005-02-09 15:16 • by LordHunter317
29347 in reply to 29346
I dunno if this is true of PL/SQL (IANA Oracle Expert) but in some
stored procedure langauges, the speed of having fixed variable names
and no loops is orders of mangitude faster than having a loop that
makes the variable names and then tests on them.  Why?



Because the IF setup can be fully prepared and cached by the server as
a single query.  The FOR Loop will require running a dynamic query
for each variable (i.e., an EXECUTE in Postgres), meaning the database
server can't prepare nearly as much of the query (as it can't assume
anyhting about the SQL it will run without a really intelligent
optimizer).



I wouldn't be shocked that if PostgreSQL as another example behaved
better with a stored proc like this than one that came up with the
variable names dynamically.



If anyone's really interested, I suppose I could test.

Re: Real Consultants Don't Use Loops

2005-02-09 15:20 • by Bustaz Kool
Alex Papadimoulis:

It's from the "professional services" division of a company that shall remain nameless.


Give us a hint.  Does this company advocate a "Redneck Lifestyle" and program in the nude?

Re: Real Consultants Don't Use Loops

2005-02-09 15:20 • by
If you could name names, we would be able to avoid hiring services from that firm...

Re: Real Consultants Don't Use Loops

2005-02-09 15:24 • by
29350 in reply to 29349
:
If you could name names, we would be able to avoid hiring services from that firm...





my guess is one of the big four accounting firms

Re: Real Consultants Don't Use Loops

2005-02-09 15:39 • by
WOW...EYES HURT...CAN'T SEE...must go get shotgun and shoot pc, it has been contaminated beyond repair!!!

Re: Real Consultants Don't Use Loops

2005-02-09 16:33 • by

I don't see anything wrong with this code...


Okay okay, I can't justify this one...[:$]

Re: Real Consultants Don't Use Loops

2005-02-09 16:38 • by

Don't companies have a thing called "code review"?


Why wasn't this caught before it went to production?


You do realize that if this went to review it would get laughed at...right?


(Please tell me you realize that.)

Re: Real Consultants Don't Use Loops

2005-02-09 16:52 • by
29359 in reply to 29357

At some places, all of the other developers are giant WTFs as well, so who's going to review the code?

Re: Real Consultants Don't Use Loops

2005-02-09 16:59 • by
29360 in reply to 29348

My "code review team" consists of a guy named Bob.


When he's not sleeping, he's surfing the web for porn. So, you can imagine what sort of "review" he does.

Re: Real Consultants Don't Use Loops

2005-02-09 17:42 • by JamesCurran
29361 in reply to 29347

LordHunter317:
I dunno if this is true of PL/SQL (IANA Oracle Expert) but in some stored procedure langauges, the speed of having fixed variable names and no loops is orders of mangitude faster than having a loop that makes the variable names and then tests on them.  Why?


Well, even if we accept the idea that loops are to be avoid, the first half is needlessly complicated by also avoiding nested IFs --- something he starts using in the second half.....

Re: Real Consultants Don't Use Loops

2005-02-09 18:23 • by
You've seen people who can't read if you make them hold their lips
still, right?  And people who can't count up to eleven unless
they're wearing open-toed sandals?  I suspect this is a guy who
couldn't write a program if you disabled the Copy and Paste items in
his Edit menu...



Why is the US government wasting money shooting Iraqis?  It should
be hunting these people down and electrocuting them in their
cubicles.  You know it makes sense.



: Bat :

Re: Real Consultants Don't Use Loops

2005-02-09 19:11 • by LordHunter317
29364 in reply to 29361
JamesCurran:

 LordHunter317 wrote:
I dunno if this is true of PL/SQL (IANA Oracle Expert) but in some stored procedure langauges, the speed of having fixed variable names and no loops is orders of mangitude faster than having a loop that makes the variable names and then tests on them.  Why?


Well, even if we accept the idea that loops are to be avoid, the first half is needlessly complicated by also avoiding nested IFs --- something he starts using in the second half.....

Re: Real Consultants Don't Use Loops

2005-02-09 19:12 • by LordHunter317
29365 in reply to 29364
Can we please get a forum that works wtih FF?



Anyway, the text of my post got b0rked:



Yes, I'll agree the layout of the code is subotimal.   But
some unfactored IF's don't really make a WTF.  Without knowing if
a looping construct for this is really more efficent, I'm not sure this
qualifies.

Re: Real Consultants Don't Use Loops

2005-02-09 19:34 • by
29366 in reply to 29365
I'm using FireFox 1.0 in Windows and having no trouble with the forum
software, though I agree it's needlessly overcomplicated.  It
would be nice to have an IP-based "re-edit my comment" feature, but
that's why every programmer is writing their own blog software...

Re: Real Consultants Don't Use Loops

2005-02-09 19:55 • by
29367 in reply to 29365
I think it would be cool if every time you posted it stamped your ip address, computer name, social security info, and mother's maiden name.

Re: Real Consultants Don't Use Loops

2005-02-09 22:33 • by Jon Limjap
Once more, repeat after me!



Loops are slow... unroll those loops because loops are slow... unroll
those loops because loops are slow... unroll those loops because loops
are slow... unroll those loops because loops are slow... unroll those
loops because loops are slow... unroll those loops because loops are
slow... unroll those loops because loops are slow... unroll those loops
because loops are slow... unroll those loops because loops are slow...
unroll those loops because loops are slow... unroll those loops because
loops are slow... unroll those loops because loops are slow........

Re: Real Consultants Don't Use Loops

2005-02-09 23:00 • by
29371 in reply to 29347
Theres nothing to prepare - there is no actual data access happeing
here. This code should really have been done in a higher level language

Re: Real Consultants Don't Use Loops

2005-02-09 23:38 • by
Loops maybe slow at times but is it better to save a few nanoseconds or
have more readable easier to maintain code? I'd fall on the side of
maintainability personally. And besides.. if you're entire app is being
slowed down by loops maybe there are some bigger problems at work here.
I've seen code that had many nested loops that was dog slow so yea they
can be bad but I refactored it into one loop and bingo, it was tons
faster and still within one loop. Most loops break down to a test and a
jump.. by itself that should not be that slow (depends on what happens
in the loop of course but just by itself loops aren't slow enough to
give up the entire class of program flow structures). In this case
someone mentioned that performing a loop might be magnitudes slower, so
yea that might be bad but until I see benchmarks showing that its
horrible enough to give up a simple loop for a small speed increase
over this WTF I'll stick with a loop..



And as an aside I hate doing loops in SQL, I do my best to keep processing out of the SP if possible.

Re: Real Consultants Don't Use Loops

2005-02-10 01:31 • by Drak
29375 in reply to 29372

I wish more people got accounts with names, and less people bitched about the forum software.


It's harder to follow all those anoymous posts than to make a decent post with the software. If you can't make a decent post, perhaps you should post EXACTLY what you did, and what went wrong.


You're all supposed to be developers right? You should know that a bug report saying: 'It doesn't work.' or 'I can't make a post.' is totally useless for the developer who wants to (and I'm certain Alex wants to make his forum cool) fix any bugs.


Drak

Re: Real Consultants Don't Use Loops

2005-02-10 01:41 • by icelava
29376 in reply to 29375
Drak:
You're all supposed to be developers right? You
should know that a bug report saying: 'It doesn't work.' or 'I can't
make a post.' is totally useless for the developer who wants to (and
I'm certain Alex wants to make his forum cool) fix any
bugs.
Developers are only developers for their own software. Anything else, they are users. [8-|]

Re: Real Consultants Don't Use Loops

2005-02-10 03:58 • by Bellinghman
29381 in reply to 29375
Drak:

I wish more people got accounts with names, and less people bitched about the forum software.


It's harder to follow all those anoymous posts than to make a decent post with the software. If you can't make a decent post, perhaps you should post EXACTLY what you did, and what went wrong.


You're all supposed to be developers right? You should know that a bug report saying: 'It doesn't work.' or 'I can't make a post.' is totally useless for the developer who wants to (and I'm certain Alex wants to make his forum cool) fix any bugs.


Drak



I hit the quote button. I went to the end of the edit box, hit enter, and typed this text. I will then hit the post button.

You can see the result.

Re: Real Consultants Don't Use Loops

2005-02-10 05:05 • by Bellinghman
29382 in reply to 29381

Bellinghman:
I hit the quote button. I went to the end of the edit box, hit enter, and typed this text. I will then hit the post button.

You can see the result.


The problem being, of course, that the software does not accept HTML (instead it wants BB). However, what it sends to the client browser does contain HTML markup codes. And when that's reflected back, it escapes the < and > characters and the user sees the tags.


The WTF is - the software cannot accept its own output as input.


The second WTF is that it does work with IE - but only by using a special control. This means that a majority of clients don't see the problem. But this is supposed to be a web site, not an IE site.


I hope that Alex will get an update soon. At present, there are three things that irritate me about this site:



  1. Quoting under my (Opera) browser. Firing up IE is something I very rarely have to do otherwise.

  2. No threading. Compare with LiveJournal, where you can easily see which posts are replying to which (and therefore quoting is needed less).

  3. The large number of anonymous postings by people who don't even have the nous to put their names at the end of their posts (I can understand the not-registering bit). It's really quite difficult to carry out a debate on a topic if you can't tell which misguided ideas your opponent is espousing, and which are someone else's. 

Point 3 is not the forum's fault, of course.


On the positive side, I'd like to say:- Alex, thanks for this site. We may moan, but it's still quite usable, and the faults aren't yours. If people didn't care, you wouldn't get the wingeing. We do know it's not your paid job, but please keep it up.

Re: Real Consultants Don't Use Loops

2005-02-10 07:07 • by smudge

That Corba posting on google is cool. I have replied. [:D]

Re: Real Consultants Don't Use Loops

2005-02-10 09:24 • by Katja
For a guy who gets paid for every line of code, I think this is a real good solution... [;)]

Re: Real Consultants Don't Use Loops

2005-02-10 09:52 • by Inkieminstrel
Where can I get one of these jobs that pays me more money to write code like that?

Re: Real Consultants Don't Use Loops

2005-02-10 10:02 • by memorex

Looks a whole lot like Andersen (err.. "Accenture" after the scandals?) code to me.


The accounting dept of a company I worked for had those guys in to write some etl/like import code and they wound up with a --30-- page stored proc to do it.

Re: Real Consultants Don't Use Loops

2005-02-10 10:43 • by Drak
29392 in reply to 29382
Bellinghman:








 Bellinghman wrote:




I hit the quote button. I went to the end of the edit box, hit enter, and typed this text. I will then hit the post button.

You can see the result.


The problem being, of course, that the software does not accept HTML (instead it wants BB). However, what it sends to the client browser does contain HTML markup codes. And when that's reflected back, it escapes the < and > characters and the user sees the tags.


This is what I'd call a good bug report. Esp. mentioning that you use a browser other than IE to browse the forum.


Does it show escaped HTML when you hit the HTML button in the editor?


Drak

Re: Real Consultants Don't Use Loops

2005-02-10 11:24 • by Raymond Chen
I'm surprised nobody yet has mentioned that in the second half, two of the three "else" branches are identical aside from spacing, and I doubt this language is sensitive to spaces.

Re: Real Consultants Don't Use Loops

2005-02-10 11:29 • by Mike R
29394 in reply to 29393

Raymond Chen:
I'm surprised nobody yet has mentioned that in the second half, two of the three "else" branches are identical aside from spacing, and I doubt this language is sensitive to spaces.


Yes.. But, do you want to take a wild guess as to how many people read all the way to the bottom of the code? (I know I didn't [:$] )

Re: Real Consultants Don't Use Loops

2005-02-10 11:35 • by
29395 in reply to 29394

I don't even look at the WTF code snippets. I just read the developer comments.


That's where the true humor lies.

Re: Real Consultants Don't Use Loops

2005-02-10 11:52 • by Bustaz Kool
29398 in reply to 29370

Jon Limjap:
Once more, repeat after me!

Loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow........


Your ideas intrigue me and I would like to subscribe to your newsletter.  Are you holding any "getting to know you" meetings in my area? [;)]

Re: Real Consultants Don't Use Loops

2005-02-10 12:21 • by
29405 in reply to 29370

Jon Limjap:
Once more, repeat after me!

Loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow... unroll those loops because loops are slow........


You know, after you read this a couple times, you get a subliminal message..."slow your roll...slow your roll..."

Re: Real Consultants Don't Use Loops

2005-02-10 14:52 • by Bustaz Kool
29420 in reply to 29375
Drak:

I wish more people got accounts with names, and less people bitched about the forum software.



I wish that the people who do the bitching (on any topic) would have the stones to sign their name to their viewpoint.

Re: Real Consultants Don't Use Loops

2005-02-10 14:57 • by
29421 in reply to 29420

Bustaz Kool:
I wish that the people who do the bitching (on any topic) would have the stones to sign their name to their viewpoint.


Never!

Re: Real Consultants Don't Use Loops

2005-02-10 23:34 • by phx

Using an alternate browser is your problem. If 90% of people do it, then it is The Standard. Its like driving around with a caravan attached to your car. Then whinging that parking spaces dont cater for your vehicle. "But it meets street legal standards!".


Sick of this ZOMG USE FIREFOX ITS THE NEW WAVE MAN crap. Until more than a few million people use it, I cant imagine anyone could be fucked going out of their way to make things work with it.

Re: Real Consultants Don't Use Loops

2005-02-11 07:53 • by
29476 in reply to 29465
Heh, another IE zealot. Well, it is site of Microsoftie guy, what I can
except? Website about WTF whom has itself WTF - how a sweet irony.



And BTW writing www pages whom work with all popular browsers is not hard.



"If 90% of people do it, then it is The Standard."

Eat shit. Trilion flys cannot be wrong!



"
Sick of this ZOMG USE FIREFOX ITS THE NEW WAVE MAN crap."

Sick of guys with attidude "were best and f*** the rest".

Re: Real Consultants Don't Use Loops

2005-02-11 14:33 • by Blue
29498 in reply to 29465


Call me crazy, but IMHO if a few million people are using it, even
though that is a small percentage compared to IE, it seems worth
considering supporting it.



IE isn't the Standard.  HTML is the standard.  IE bastardizes
that by using non-standard HTML and JavaScript constructs, as well as
utilizing a plethora of whiz-bang Active-X plug-ins to try to make sure
they stay "the standard", meanwhile opening up gazillions of security
holes due to it.



I love looking at Page Properties in Firefox when viewing sites - the
IE-centric ones all require Firefox to use a rendering mode called
"Quirks", which by my understanding means it has to attempt to
interpret the page like IE would, since it doesn't follow
standards.  I could easily be wrong here, and feel free to educate
me.





Re: Real Consultants Don't Use Loops

2005-02-11 14:37 • by Blue
29499 in reply to 29498
Furthermore, a big reason for 90% usage is that it comes with the OS,
most end users are too lazy / incompetent to get a better (or at least
different, depending on your viewpoint) browser, which causes people to
end up designing sites that work best in it (IE), which in turn causes
the vicious cycle that has brought us to where we are today.



I also agree strongly with the earlier post that it isn't that hard to write multiple-browser compatible pages.









Re: Real Consultants Don't Use Loops

2005-02-11 14:45 • by
29500 in reply to 29498
Actually, Quirks mode is entered when the doc type of the page is not
declared correctly.  Since almost no design applications actually
declare the doc type correctly, Firefox renders most sites in Quirks
mode.



Not really IE's fault, but it is symptomatic of lax coding techniques
that I've noticed many IE-only developers fall into...bit of a flame, I
know, but 'tis true.

Re: Real Consultants Don't Use Loops

2005-02-11 15:07 • by Blue
29507 in reply to 29500
Thanks for the clarification - as I said I'm not yet familiar with the
ins-and-outs of FireFox, but for my personal use, I strongly prefer
it.  Even with the quirks that it admittedly has.



In particular, I really like AdBlock and the Web Developer toolbar
extensions, Mouse Gesture extensions, ability to easily theme/skin the
interface, and several features that I don't find as easily accessible
(or in some cases present at all!) for IE.     !



I can't even do tabbed browsing in IE unless I install CrazyBrowser or
Avant or something similar. (IE lovers, feel free to correct me if I'm
wrong.)





Re: Real Consultants Don't Use Loops

2005-02-11 15:27 • by Stan Rogers
29511 in reply to 29507
You're right about the tabbed interface -- and it was discussed in the
IE community (the folks who develop IE, not those who develop for it).
I wish I still had the link to that discussion. That suggestion caused
quite the furor, since it breaks with the "document" interface standard
that MS has been trying to push. (Note that every Word doc or Excel
sheet opens in its own window, with its own taskbar entry if you
haven't selected the "stack" option.) There are some very bright people
out there who firmly believe that users don't want an application open,
they want a document. I don't happen to agree, but I'm not on the UI
standards team at MS. Until the SDI interface standard goes away,
neither IE nor its heirs and assigns are ever likely to come with tabs
"out of the box".

Re: Real Consultants Don't Use Loops

2005-02-11 17:05 • by Blue
29518 in reply to 29511
Thanks for your comment.



I note that they don't strictly conform to that in Excel - note the
Workbook concept, with tabbed worksheets.   So they do
understand on some level that we mere humans are capable of using MDI
apps.



At the very least, make it optional and disabled by default!!









Re: Real Consultants Don't Use Loops

2005-02-12 07:32 • by
this is just plain good ol' loop unrolling

« PrevPage 1 | Page 2Next »

Add Comment