Comment On Pipe Dreams

When digging into a newly inherited codebase, most experienced developers have a preferred way to break the system down into understandable pieces. Most of course start with the documentation, but since there rarely is any, that leaves one of two approaches: back-end to front-end or front-end to back-end. John, a Java and SQL developer, generally likes to start in the database and work his way to the front-end. [expand full text]
« PrevPage 1 | Page 2Next »

Re: Pipe Dreams

2010-05-17 09:13 • by @Deprecated (unregistered)
So the code seems to actually use result set fields, but not by name... and then strips off the last character. Weird.

All fields are strings! Bonus! That will make it easy to migrate to another database.




Re: Pipe Dreams

2010-05-17 09:24 • by ParkinT
...the developer should have been halved

Drawn and Quartered, at least!

Re: Pipe Dreams

2010-05-17 09:30 • by Josephus (unregistered)

-- define query at a high level
SELECT TDate = something,
ID = something, -- space(7)
Reference = something, -- space(12)
...
Price = something,
...
FROM Detail

Re: Pipe Dreams

2010-05-17 09:30 • by Michael (unregistered)
308933 in reply to 308931
ParkinT:
...the developer should have been halved

Drawn and Quartered, at least!

"Piped" you mean

Re: Pipe Dreams

2010-05-17 09:31 • by Doc (unregistered)
Looks like someone once wrote the query to output delimited, fixed width columns for a printed report. Then a later developer came along and used the same query to feed the on-screen display, and no longer needed the column delimiters since the values were being stuffed into table cells - which presumably would have had their own grid styles.

A prime example of why code re-use may be the fastest way, but not the most supportable. Sometimes, you should just re-write.

Re: Pipe Dreams

2010-05-17 09:36 • by Anonymous (unregistered)
Looking forward to the narration on this one. It'll be interesting to see how they handle indexed data...

"Table data open square bracket zero close square bracket equals get substring open bracket job list rs dot get string open bracket one close bracket close bracket semi colon."

Nice!

Re: Pipe Dreams

2010-05-17 09:41 • by Kempeth (unregistered)
Duh! Never heard of Pipe terminated strings?

Very similar to null terminated strings but with support for null characters!

Re: Pipe Dreams

2010-05-17 09:44 • by TehShrike
308937 in reply to 308936
Kempeth:
Duh! Never heard of Pipe terminated strings?

Very similar to null terminated strings but with support for null characters!


You made me laugh in the middle of a tasty drink! I'd be angry at you if I wasn't still giggling.

Re: Pipe Dreams

2010-05-17 09:50 • by BSDPwns (unregistered)
"Pipe terminated strings"


awwwww yeah.

Re: Pipe Dreams

2010-05-17 09:51 • by ubersoldat
That's Java? It looks too much like VB except for all the "let"s. Anyway, if this is the DAO layer, you're gonna have fun with the presentation layer. Yeah! Swing can make your life a living hell.

Re: Pipe Dreams

2010-05-17 09:57 • by wtf (unregistered)
308940 in reply to 308939
ubersoldat:
That's Java? It looks too much like VB except for all the "let"s. Anyway, if this is the DAO layer, you're gonna have fun with the presentation layer. Yeah! Swing can make your life a living hell.


I think Artie Shaw said the same thing...

Re: Pipe Dreams

2010-05-17 10:01 • by Whiskey, Eh? (unregistered)
Oh, I see. The real WTF is that they should have used a loop to copy all those tableData[] strings instead of hand-writing all 31 lines.

Re: Pipe Dreams

2010-05-17 10:03 • by DCRoss
Ceci n'est pas une pipe.

Re: Pipe Dreams

2010-05-17 10:08 • by Tres bon, Magritte (unregistered)
308943 in reply to 308942
DCRoss:
Ceci n'est pas une pipe.

Re: Pipe Dreams

2010-05-17 10:08 • by Carl (unregistered)
Well, so, I saw this guy doing some amazing things on Unix, and all I remember is he used a whole lotta pipes, so I started using pipes wherever I could. It makes me feel, um, all Unixy.

Re: Pipe Dreams

2010-05-17 10:22 • by Martijn Lievaart (unregistered)
308947 in reply to 308939
ubersoldat:
That's Java? It looks too much like VB except for all the "let"s. Anyway, if this is the DAO layer, you're gonna have fun with the presentation layer. Yeah! Swing can make your life a living hell.


A DAO layer? I think you mean a DOA layer!

M4

Re: Pipe Dreams

2010-05-17 10:29 • by Jaime
308948 in reply to 308939
ubersoldat:
That's Java? It looks too much like VB except for all the "let"s. Anyway, if this is the DAO layer, you're gonna have fun with the presentation layer. Yeah! Swing can make your life a living hell.
Nobody's used "Let" in VB in twenty five years. Also, the semicolons and curly braces pretty much rule out a VB-like language.

Re: Pipe Dreams

2010-05-17 10:32 • by Markp
308949 in reply to 308942
DCRoss:
Ceci n'est pas une pipe.

Win.

Re: Pipe Dreams

2010-05-17 10:36 • by Anonymously Yours (unregistered)
It almost looks like someone clever decided to piss away some of his development time trying to format result sets the same way they come out in command line. Of course, I might just be trying to place reason where none could survive.

Re: Pipe Dreams

2010-05-17 10:39 • by Vilx-
I can see it now. The real reason behind all this pipedness is because Once Upon A Time there was a Chief Software Architect who wrote all this application by himself. Since he didn't trust in those fancy graphical SQL tools, he wrote his own console-mode querying software. After all, graphical tools are dreadful resource hogs, filled with bugs, very limited in their functionality, and all in all just too feminine for a Real Man like him. Unfortunately when it came to displaying query results, there was just no appropriate language construct to display a separator between the cell values, so he modified the cell values to print out pretty...

Now, as for why every query requires to select exactly 31 cells, that's a bit of an embarrassing story which will not be told here.

Re: Pipe Dreams

2010-05-17 10:42 • by SeySayux (unregistered)
308952 in reply to 308942
DCRoss:
Ceci n'est pas une pipe.

http://seysayux.users.sourceforge.net/cecinestpasunpipe.jpg

Re: Pipe Dreams

2010-05-17 10:47 • by Procedural (unregistered)
308954 in reply to 308936
Kempeth:
Duh! Never heard of Pipe terminated strings?

Very similar to null terminated strings but with support for null characters!


Yes. And the nice thing about lpstr types is that you can have a pipe in them just by escaping them with a null.

Re: Pipe Dreams

2010-05-17 10:54 • by db2
Probably some dumb garbage that relies on the fields being returned from the database padded out with spaces, and a developer that doesn't understand fixed-width CHAR data types, ANSI padding, etc.

Re: Pipe Dreams

2010-05-17 11:08 • by davee123 (unregistered)
If I had to guess, I would say this was probably debug code that never got removed. Printing out the raw data in a fixed-width font would show columns of data with pipes as dividers between fields, yes? So the original dev may have been tweaking the query, and printing it out to verify it. Then, when it came time to production-ize the code, never re-wrote it to remove the pipes. Possibly because he may have wanted to print it out for future debugging.

DaveE

Re: Pipe Dreams

2010-05-17 11:11 • by Shriike (unregistered)

SELECT TDate = TDate +"|",
ID = "0000000"+"|", -- space(7)
Reference = " "+"|", -- space(12)
FROM Detail

Now correct me if I'm wrong, but don't ID and Reference not actually return real data? ID should just return "0000000|" and reference should just return 12 spaces followed by a |.

But I really like the comments. "Width of 7 field", or "7 spaces" was too much typing, so just "space(7)".

Re: Pipe Dreams

2010-05-17 12:01 • by Max (unregistered)
308959 in reply to 308942
DCRoss:
Ceci n'est pas une pipe.


How is this not a featured comment yet?

Re: Pipe Dreams

2010-05-17 12:26 • by NetTears (unregistered)
TRWTF is starting development with the database.

Re: Pipe Dreams

2010-05-17 12:41 • by jasmine2501
308964 in reply to 308957
Shriike:

SELECT TDate = TDate +"|",
ID = "0000000"+"|", -- space(7)
Reference = " "+"|", -- space(12)
FROM Detail

Now correct me if I'm wrong, but don't ID and Reference not actually return real data? ID should just return "0000000|" and reference should just return 12 spaces followed by a |.

Yes, that's TRWTF... the columns come back as separate columns just like normal, but with a | at the end... and converted to strings.

Re: Pipe Dreams

2010-05-17 12:49 • by The Emperor (unregistered)
308965 in reply to 308932
Josephus:

-- define query at a high level
SELECT TDate = something,
ID = something, -- space(7)
Reference = something, -- space(12)
...
Price = something,
...
FROM Dark_Side

FTFY

Re: Pipe Dreams

2010-05-17 13:12 • by Resistance
I once had a nightmare of 0|1|1|1|1|1|0|0

Re: Pipe Dreams

2010-05-17 13:20 • by fjf (unregistered)
308968 in reply to 308937
TehShrike:
You made me laugh in the middle of a tasty drink! I'd be angry at you if I wasn't still giggling.

Don't drink and read TDWTF!

Re: Pipe Dreams

2010-05-17 13:28 • by immitto (unregistered)
308969 in reply to 308959
Max:
DCRoss:
Ceci n'est pas une pipe.


How is this not a featured comment yet?

TRWTF is French.

Re: Pipe Dreams

2010-05-17 13:37 • by ¿Que? (unregistered)
308970 in reply to 308959
Max:
DCRoss:
Ceci n'est pas une pipe.


How is this not a featured comment yet?


Not sure why "This is not a pipe" scores big. Am I missing something?

Re: Pipe Dreams

2010-05-17 13:38 • by Food4Thought (unregistered)
308971 in reply to 308938
Technically there is a whole class of strings with arbitrary terminators. This allows any character to be represented in a string including nulls and pipes. The trick is that the terminator character is also placed the beginning of the string so that the parser knows which terminator character to look for in that particular string. Clever, eh? I think it's called the Minimally Efficient String Style or something...

Re: Pipe Dreams

2010-05-17 13:46 • by Mike D. (unregistered)
308972 in reply to 308951
Vilx-:
I can see it now. The real reason behind all this pipedness is because Once Upon A Time there was a Chief Software Architect who wrote all this application by himself. Since he didn't trust in those fancy graphical SQL tools, he wrote his own console-mode querying software. After all, graphical tools are dreadful resource hogs, filled with bugs, very limited in their functionality, and all in all just too feminine for a Real Man like him. Unfortunately when it came to displaying query results, there was just no appropriate language construct to display a separator between the cell values, so he modified the cell values to print out pretty...

I don't think it was a matter of trusting GUI tools. More likely it was a matter of never having used them and being far more trusting of printf-style debugging and logging. Debugging code and production code being the same code... I can see how a clever dev could sell that on a PowerPoint.

Vilx-:
Now, as for why every query requires to select exactly 31 cells, that's a bit of an embarrassing story which will not be told here.

Probably just the maximum number of fields in the whole database. This allows code reuse or something. Yeah, it's lame.

Re: Pipe Dreams

2010-05-17 13:48 • by Mike D. (unregistered)
308974 in reply to 308971
Food4Thought:
Technically there is a whole class of strings with arbitrary terminators. This allows any character to be represented in a string including nulls and pipes. The trick is that the terminator character is also placed the beginning of the string so that the parser knows which terminator character to look for in that particular string. Clever, eh? I think it's called the Minimally Efficient String Style or something...

So long as you never need more than 255 distinct byte values in a string, it's a workable idea. A length prefix removes this limit at the cost of a couple more bytes.

Re: Pipe Dreams

2010-05-17 14:13 • by Markp
308977 in reply to 308970
¿Que?:
Max:
DCRoss:
Ceci n'est pas une pipe.


How is this not a featured comment yet?


Not sure why "This is not a pipe" scores big. Am I missing something?


Yes, and Google is your friend.

Re: Pipe Dreams

2010-05-17 14:17 • by Al Burnett (unregistered)
The developer of the pipe seperated strings apparently was using a pipe - the crack pipe!

CAPTCHA: odio - Odio mio, this code is terrible!

Re: Pipe Dreams

2010-05-17 14:43 • by J (unregistered)
308980 in reply to 308934
Doc:
Looks like someone once wrote the query to output delimited, fixed width columns for a printed report. Then a later developer came along and used the same query to feed the on-screen display, and no longer needed the column delimiters since the values were being stuffed into table cells - which presumably would have had their own grid styles.

A prime example of why code re-use may be the fastest way, but not the most supportable. Sometimes, you should just re-write.


First paragraph: You're probably right.

Second paragraph: A prime example of why you don't use SQL to format for display.

Re: Pipe Dreams

2010-05-17 14:51 • by Axl (unregistered)
308981 in reply to 308959
Max:
DCRoss:
Ceci n'est pas une pipe.


How is this not a featured comment yet?


Ceci n'est pas un commentaire en vedette

Re: Pipe Dreams

2010-05-17 14:53 • by Axl (unregistered)
308982 in reply to 308977
Markp:
¿Que?:
Max:
DCRoss:
Ceci n'est pas une pipe.


How is this not a featured comment yet?


Not sure why "This is not a pipe" scores big. Am I missing something?


Yes, and Google is your friend.


Google image search is your friend.

Re: Pipe Dreams

2010-05-17 15:18 • by inhibeo (unregistered)
308983 in reply to 308959
Max:
DCRoss:
Ceci n'est pas une pipe.


How is this not a featured comment yet?

It probably has something to do with embedded systems not having access to comments.

Re: Pipe Dreams

2010-05-17 15:21 • by tation (unregistered)
308984 in reply to 308959
Max:
DCRoss:
Ceci n'est pas une pipe.


How is this not a featured comment yet?

Have you tried faxing the comment to the ftp site yet?

Re: Pipe Dreams

2010-05-17 15:24 • by da Doctah
308985 in reply to 308969
immitto:
Max:
DCRoss:
Ceci n'est pas une pipe.


How is this not a featured comment yet?

TRWTF is French.


Have it your own way:

http://members.cox.net/bagelhenge/pipasig.jpg

Re: Pipe Dreams

2010-05-17 15:34 • by EngleBart (unregistered)
308986 in reply to 308974
You also need to factor in Godel's incompleteness theorem when talking about string delimiters...

My theory for this article is that the data was originally stored in a file that was migrated to a table.

Re: Pipe Dreams

2010-05-17 15:37 • by luctus (unregistered)
308987 in reply to 308986
EngleBart:
You also need to factor in Godel's incompleteness theorem when talking about string delimiters...

My theory for this article is that the data was originally stored in a file that was migrated to a wooden table.


FTFY

Re: Pipe Dreams

2010-05-17 17:07 • by bshock (unregistered)
308988 in reply to 308936
The code is obviously stupid, but I've seen plenty of legacy situations that lead to this sort of thing. You start out with some sort of ancient front end that was originally written for flat files or something like that, and then a bright manager decides to add a db to it. There's no time to do things the right way from the start, so they just slide the db into place within the previous interface. Then, when better things come along, no one ever bothers to refactor the app to leverage real relational db power.

In my last job, there was a C++ legacy app that had originally used an old version of Btrieve. A few years before, some bright coder sold management the idea of moving to SQL Server. But instead of creating a normalized db with referential integrity, he just ported the Btrieve interface to SQL Server. The thing ran incredibly slowly and required an entire day just to add one field to a table. (There were other issues as well.)

Re: Pipe Dreams

2010-05-17 18:06 • by arrowdrive (unregistered)
I don't know. I've seen far better ;)

Where I work now we have an application that uses XML from a normal database. In itself not that unusual, except it runs a procedure on the database, exports the result set to a file in XML (and no it does not use SQL's ability to create the XML) then reads the file into the application....

Re: Pipe Dreams

2010-05-17 18:07 • by method1
308990 in reply to 308987
luctus:
EngleBart:
You also need to factor in Godel's incompleteness theorem when talking about string delimiters...

My theory for this article is that the data was originally stored in a file that was migrated to a wooden table.

FTFY


Excellent, +1

Re: Pipe Dreams

2010-05-17 21:15 • by Arlen Cuss (unregistered)
308992 in reply to 308936
Only now you have to escape pipes (with nulls).
« PrevPage 1 | Page 2Next »

Add Comment