Comment On The Path to WTF is Paved with Good Intentions

Let's say that I have a stupid report that needs constant attention and maintenance because of waffling business requirements.  Rather than buying a fruit bouquet for the server admin because of all the promotes I'd be doing, one solution might be to dynamically fetch the SQL for the report from a table. That way, all I would need to do is run a single UPDATE statement, COMMIT, and it's done! [expand full text]
« PrevPage 1 | Page 2Next »

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 08:03 • by Jakey C (unregistered)

'intenet' = what you plan to do on the internet

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 08:07 • by anonym (unregistered)
ok ... ?

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 08:07 • by random_garbage
// adds some params to his query here
cmdText = this.ParseQuery(obj2.ToString(), ref xnParameters);
I especially like the fact that instead of using standard parameterized queries, he's invented his own templating language!

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 08:13 • by A Nonny Mouse
i don't understand why this is all fine... until we see the table.

?

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 08:16 • by Inhibeo (unregistered)
This is obviously the more robust choice. Twenty years ago you'd be laughed at for suggesting we might add new genders to our species. We now have male, female, trans-gender, non-actualized, multiple, and "none."

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 08:18 • by snoofle
We did something similar (table of queries) but in shell script (there wasn't enough time to finish the app and this allowed us to short circuit a lot of the as yet uncoded processing). The understanding was that the code still HAD to be written and this hack HAD to go away.

Naturally, nobody considered it urgent after delivery so it lived on... until the auditors came along. Heads rolled, butts were kicked, and suddenly there was time to finish the work.

Every once in a while you win one...

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 08:27 • by Bob (unregistered)
Where's the WTF?

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 08:28 • by Anon (unregistered)
select code, description from referencedata where codetype = 'YESNO' order by sortorder


Wha-

Nevermind, probably better not to ask.

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 08:47 • by Médinoc (unregistered)
244604 in reply to 244602
It's in the queries themselves.

All those selects from the table "referencedata" with a code mean that not only the queries are softcoded, but the schema as well.

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 08:47 • by Rob (unregistered)
Hey, wait a second. A bunch of these aren't reports AT ALL!

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 08:48 • by Rob (unregistered)
244606 in reply to 244600
So? You can update the codebase for something like that.

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 08:50 • by Charles400
select employee_phone from employee_table where employee_title = 'IRISH GIRL'

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 08:50 • by Chris B (unregistered)
The real WTF came before the "Well, before firing back in the comments "Where's the WTF?""

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 08:51 • by Zecc
INSERT INTO datacommand (CommandName, Query, QueryDescription) VALUES ('CandyUnicornsAndOMGKittens', 'drop table referencedata;', 'Execute this and wonderful things will happen :)')

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 08:53 • by Vilx- (unregistered)
Reinventing the Stored Procedures, eh? ;)

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 08:54 • by IByte (unregistered)
How about adding a query to show all queries from the query table (or would that be too self-referential)?

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 09:02 • by Allov (unregistered)
244613 in reply to 244610
rofl

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 09:11 • by Martin (unregistered)
Seems like he could have just used stored procedures... and not reinvent wheels.

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 09:11 • by Jay (unregistered)
I actually worked on a system once that was worse than this. It used XML files to define the stored procs in the system. It worked like this:

Each stored procedure had an XML file that described it. So if I was writing uspGetCustomerOrders, I had to create an xml file GetCustomerOrders.xml that enumerated all the parameters to that proc and their types.

Then each COM component had an XML file that mapped function name to stored procedure name. So if I was writing the getCustomerOrders method in the blOrders component, I had to open blOrders.xml and add an entry to map getCustomerOrders -> GetCustomerOrders.xml.

Really.

So the process of calling a stored proc at runtime from a method was:

1. Open the XML doc for the component you're in
2. Lookup the name of your method, find the SP definition
3. Open the XML doc for the proc definition
4. Fill in the proc definition with parameter values
5. Pass the proc definition to a generic routine to run it and, optionally, retrieve a rowset.

That's right, twice to the drive and twice into the XML DOM for every single data call. Did I mention this was a web app?

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 09:21 • by Fabian
Of course the description column should not be nullable. Major WTF!

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 09:30 • by Corporate Cog (unregistered)
The proper colloquialism is "the code to hell is paved with good intentions." - Pete Goodliffe

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 09:31 • by Steenbergh (unregistered)
Well, it DOES beat recompiling for every query change...

Or do admins here revoke accounts based on saying such things?

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 09:32 • by GooberMcNutly
Haven't any of you worked with demon DBAs that will make you fill out forms in triplicate for any and all stored procedure changes, index creations, field additions or modifications or even, horrors, a new table?

I have written whole modules just to get around the stifling bureaucracy. Selecting SQL from a table is small potatoes.

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 09:33 • by Kempeth (unregistered)
This is obviously an ingenious solution. By routing every db operation through the same method you decrease the application memory footprint by improving code reuse and assure flexibility to provide future updates and extensions with a minimum of code modifications...

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 09:35 • by Benny (unregistered)
244628 in reply to 244601
I just recently did a table of queries. I got sick of running exports for BHB's all the time for ad-hoc queries. These are things that are common enough to bother me, but not used enough to write a report page. So I have a page that displays all the query choices and lets them export the results as html or csv...

Yeah, I know it's probably not the best way to do it, but it's saved me a lot of time.

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 09:38 • by aaawww (unregistered)
244629 in reply to 244627
@Kempeth: you should apply to that 50000$/yr management positions. how good are you at powerpointing?

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 09:44 • by RayMarron
Laugh all you want, but I actually have had to add more genders to a system! It was an appointment system & a veterinary clinic decided to use it. In addition to Unknown, Male & Female, they also needed Neutered Male & Spayed Female.

However in this case, rather than make our hardcoded gender fields enterprisey and extendible, I just misused a different extensible field for this customer.

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 09:50 • by Patrick (unregistered)
244634 in reply to 244603
select code, description from referencedata where codetype = 'YESNO' order by sortorder


you knew someone would say it:

====================
|code |description |
====================
|0 |Yes |
|1 |No |
|2 |FileNotFound|
|3 |true |
|4 |false |
|5 |ON |
|6 |OFF |
|7 |<undefined> |
====================

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 09:53 • by Foggen (unregistered)
I hate database WTFs...

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 10:11 • by Megalonychidae (unregistered)
244637 in reply to 244631
For an English Website I had to add the title options Mr, Mrs, Ms and Other.

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 10:18 • by bothwell (unregistered)
244640 in reply to 244637
Megalonychidae:
For an English Website I had to add the title options Mr, Mrs, Ms and Other.


Miss, Dr, Professor, Reverend... :/

What's the problem?

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 10:24 • by Megalonychidae (unregistered)
244641 in reply to 244640
bothwell:
Megalonychidae:
For an English Website I had to add the title options Mr, Mrs, Ms and Other.


Miss, Dr, Professor, Reverend... :/

What's the problem?


Yeah, right. The selection 'other' makes the person obviously a professor.

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 10:27 • by kastein
244642 in reply to 244637
Megalonychidae:
For an English Website I had to add the title options Mr, Mrs, Ms and Other.


I've seen signup pages that had over four screens worth of titles available. I barely resisted the temptation to list myself as a Rear Admiral or Pope.

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 10:30 • by Anon (unregistered)
244645 in reply to 244641
Megalonychidae:
bothwell:
Megalonychidae:
For an English Website I had to add the title options Mr, Mrs, Ms and Other.


Miss, Dr, Professor, Reverend... :/

What's the problem?


Yeah, right. The selection 'other' makes the person obviously a professor.


Actually, it does annoy me when websites don't have an option for Dr. I earn the title and I'd like to use it once in awhile.

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 10:38 • by snoofle
244648 in reply to 244645
Anon:
Megalonychidae:
bothwell:
Megalonychidae:
For an English Website I had to add the title options Mr, Mrs, Ms and Other.


Miss, Dr, Professor, Reverend... :/

What's the problem?


Yeah, right. The selection 'other' makes the person obviously a professor.


Actually, it does annoy me when websites don't have an option for Dr. I earn the title and I'd like to use it once in awhile.
My place wouldn't give me business cards, so I made up some joke business cards with the title: Grand Imperial Wizard of All Things Great and Small, but it's never in those on-line lists.

Where is the Internet Complaint Department?

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 10:38 • by valerion
244649 in reply to 244618
Jay:
I actually worked on a system once that was worse than this. It used XML files to define the stored procs in the system. It worked like this:

Each stored procedure had an XML file that described it. So if I was writing uspGetCustomerOrders, I had to create an xml file GetCustomerOrders.xml that enumerated all the parameters to that proc and their types.

Then each COM component had an XML file that mapped function name to stored procedure name. So if I was writing the getCustomerOrders method in the blOrders component, I had to open blOrders.xml and add an entry to map getCustomerOrders -> GetCustomerOrders.xml.

Really.

So the process of calling a stored proc at runtime from a method was:

1. Open the XML doc for the component you're in
2. Lookup the name of your method, find the SP definition
3. Open the XML doc for the proc definition
4. Fill in the proc definition with parameter values
5. Pass the proc definition to a generic routine to run it and, optionally, retrieve a rowset.

That's right, twice to the drive and twice into the XML DOM for every single data call. Did I mention this was a web app?



I feel your pain - I work with something very similar. Everything is defined in XML (and displayed with XSL) for all core DB access. It means you can add a field to the system by simply adding it to the DB, then to the XML (to read/write it) and the XSL (to display it). Now, I'm a programmer... adding a field in code should be too taxing, but whatever. It was fine until I wanted to add a WHERE clause conditionally on something else. There was just no way to do it.

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 10:50 • by silent d (unregistered)
244650 in reply to 244649
valerion:
Jay:


So the process of calling a stored proc at runtime from a method was:

1. Open the XML doc for the component you're in
2. Lookup the name of your method, find the SP definition
3. Open the XML doc for the proc definition
4. Fill in the proc definition with parameter values
5. Pass the proc definition to a generic routine to run it and, optionally, retrieve a rowset.

That's right, twice to the drive and twice into the XML DOM for every single data call. Did I mention this was a web app?



I feel your pain - I work with something very similar. Everything is defined in XML (and displayed with XSL) for all core DB access. It means you can add a field to the system by simply adding it to the DB, then to the XML (to read/write it) and the XSL (to display it). Now, I'm a programmer... adding a field in code should be too taxing, but whatever. It was fine until I wanted to add a WHERE clause conditionally on something else. There was just no way to do it.


Clearly this should have been implemented as a table with one column, of datatype LOB, containing XML. That would be totally extensible and enterprisey.

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 11:04 • by OldCoder (unregistered)
244653 in reply to 244631
RayMarron:
Laugh all you want, but I actually have had to add more genders to a system! It was an appointment system & a veterinary clinic decided to use it. In addition to Unknown, Male & Female, they also needed Neutered Male & Spayed Female.

However in this case, rather than make our hardcoded gender fields enterprisey and extendible, I just misused a different extensible field for this customer.

(Clamps legs together)

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 11:12 • by Ilya (unregistered)
Heh.. On my previous work I had an idea, that should help us (developers) to avoid system administrators when we visited the production site.
My genius solution was to create a loader, which then connected to the DB, fetches the latest dll for this project, then places it in the memory and after that executes dllmain.
I don't know was it good or bad, but i never got time to finish this part. :)

But we implemented a lot of other "cool" stuff in it. I feel sorry for the guy, who is maintaining this project now.

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 11:27 • by ShatteredArm (unregistered)
244660 in reply to 244608
Chris B:
The real WTF came before the "Well, before firing back in the comments "Where's the WTF?""


I agree. TRFTW is that the DBAs even let anyone run queries against a production database. I thought it was pretty much standard practice in any enterprise to restrict applications to only stored procedures, and to disable sp_execsql.

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 11:34 • by lolwtf
I can do one better.

OleDbConnection connection = new OleDbConnection(gobjConfig.GetConnectionString());
connection.Open();
program = "select code from program where function = " + szFuncName;
OleDbCommand command = new OleDbCommand(cmdText, connection);
object obj2 = command.ExecuteScalar();

eval(obj2.ToString());

connection.Close();
connection.Dispose();
command.Dispose();

There. Never need to update the program again. Just change the queries in the database.

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 11:43 • by Anon (unregistered)
244667 in reply to 244634
Patrick:
select code, description from referencedata where codetype = 'YESNO' order by sortorder


you knew someone would say it:

====================
|code |description |
====================
|0 |Yes |
|1 |No |
|2 |FileNotFound|
|3 |true |
|4 |false |
|5 |ON |
|6 |OFF |
|7 |<undefined> |
====================


lolwut

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 11:47 • by Dr. Evil (unregistered)
244671 in reply to 244645
Anon:
Megalonychidae:
bothwell:
Megalonychidae:
For an English Website I had to add the title options Mr, Mrs, Ms and Other.


Miss, Dr, Professor, Reverend... :/

What's the problem?


Yeah, right. The selection 'other' makes the person obviously a professor.


Actually, it does annoy me when websites don't have an option for Dr. I earn the title and I'd like to use it once in awhile.


I didn't go to 7 years of evil medical school to be called Mr.!

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 11:50 • by Tilman Baumann (unregistered)
cmdText = "select query from datacommand where commandname = " + szText

Is this really the right way to do it on Windows?
Constructing query strings by hand is in my world dangerous crap from the 70s.

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 12:07 • by Your Name (unregistered)
This sort of describes my current project ... only it's the harmless version.
SQL snippets are stored in Excel templates, then concatenated by the software to one massive statement (7 pages in Word) only to retrieve 1 line of data (with > 100 columns) which is written back to the Excel template and then sent to the client as an Excel sheet - with the original SQL snippets still existing in "hidden" cells. And this is just one major WTF in the whole thing!

Luckily, my task is a total rewrite to get rid of such madness.

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 13:11 • by Zerbs (unregistered)
244698 in reply to 244673
Tilman Baumann:
cmdText = "select query from datacommand where commandname = " + szText

Is this really the right way to do it on Windows?
Constructing query strings by hand is in my world dangerous crap from the 70s.


no, it is not the right way, OLE DB / ADO have always supported a parameters collection. Even RDO (the predecessor to ADO) supported some parameterization, and that's going back to the VB 5 days.

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 13:37 • by KattMan
244705 in reply to 244660
ShatteredArm:
Chris B:
The real WTF came before the "Well, before firing back in the comments "Where's the WTF?""


I agree. TRFTW is that the DBAs even let anyone run queries against a production database. I thought it was pretty much standard practice in any enterprise to restrict applications to only stored procedures, and to disable sp_execsql.


The exact opposite happens in my company. For some reason the DBA's are afraid of Stored Procs, but not afraid of rouge queries in our code.

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 13:46 • by Vic Tim (unregistered)
244710 in reply to 244624
Corporate Cog:
The proper colloquialism is "the code to hell is paved with good intentions." - Pete Goodliffe


s/good\ intentions/cool\ inventions

$0.02 please

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 13:49 • by Code Dependent
244713 in reply to 244624
Corporate Cog:
The proper colloquialism is "the code to hell is paved with good intentions." - Pete Goodliffe
Not to mention the code from hell.

Re: The Path to WTF is Paved with Good Intentions

2009-02-18 13:53 • by Joe Mama (unregistered)
244715 in reply to 244645
Anon:
Actually, it does annoy me when websites don't have an option for Dr. I earn the title and I'd like to use it once in awhile.


Poor baby. Sounds like you "earn the title" AMF as well (A = arrogant).
« PrevPage 1 | Page 2Next »

Add Comment