Comment On The Marshal

When Eli accepted a position nicknamed The Marshal, he knew he’d be in for a challenge. For many years, the company’s culture was dominated by cowboy coders and a frontiersmen attitude of just get’er done. Though many of the code-slingers had long since retired, the spirit of the Wild West still remained. [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: The Marshal

2011-02-14 09:04 • by Oracle Marketer (unregistered)
Oracle is great for all things enterprise. Enterprise data storage, enterprise basic mathematics, it has it all!

Re: The Marshal

2011-02-14 09:05 • by BlackBart (unregistered)
It's FutureProof! They can add variable discounts in the future from the DB by just modifying the SQL statement and the DB.

Re: The Marshal

2011-02-14 09:08 • by steenbergh
OMG! Eli totally screwed up the descriptive method name by not using SQL!

Re: The Marshal

2011-02-14 09:12 • by frits
OK, so we know where the Marshal is. But where's LeBeouf?

Re: The Marshal

2011-02-14 09:12 • by Ben (unregistered)
I suspect they wanted to use fixed-point numbers when handling currency. Alas, the parameter and return types are all floating-point, which is TRWTF.

Captcha: Your mother is an ULLAMCORPER.

Re: The Marshal

2011-02-14 09:17 • by Qvazar (unregistered)
But the original returns 0 if the DUAL table is empty... :S

Re: The Marshal

2011-02-14 09:18 • by Mojo (unregistered)
Ugh. If you need to have the differences between Plain Old Code Subtraction (POCS) and Advanced DBMS Subtraction (ADS) explained to you, then you shouldn't be coding at all.

Oh, I know, "they both return exactly the same results".

/facepalm

Get a brain, morans!

:D

Re: The Marshal

2011-02-14 09:19 • by Mr obvious (unregistered)
337588 in reply to 337585
Qvazar:
But the original returns 0 if the DUAL table is empty... :S

You haven't used Oracle much, have you?

Re: The Marshal

2011-02-14 09:20 • by andres (unregistered)
He should have used a stored procedure. That's TRWTF

Re: The Marshal

2011-02-14 09:28 • by no name (unregistered)
337594 in reply to 337588
Mr obvious:
Qvazar:
But the original returns 0 if the DUAL table is empty... :S

You haven't used Oracle much, have you?


I read Qvazar's comment as a joke, but it's possible that s/he hasn't used Oracle, in which case: what of it? If you haven't used Oracle it's not a dumb comment.

For anyone who doesn't know, DUAL is a stupidly-named built-in read-only table containing exactly one row and column, for use in situations like this.

(Well, not exactly in situations like this, but you get the point.)

Re: The Marshal

2011-02-14 09:29 • by TST (unregistered)
Looks like code that once needed something from the database (e.g. tax information) which was subsequently removed so just the substraction was left. I guess there was no source control information about it, so the history is unknown.

Re: The Marshal

2011-02-14 09:29 • by Mikey (unregistered)
337596 in reply to 337588
But if the DB is down or any other exception is thrown, a big old zero is returned. I guess if the DB is down, everything's free!

Re: The Marshal

2011-02-14 09:31 • by tkyte (unregistered)
337597 in reply to 337588
read the code. resp is defaulted to 0.

if(rs.first()) resp = rs.getDouble("result");

If there is a row, it gets a value, otherwise it leaves resp alone.

and then returns it.

The original poster got it right - it returns 0 if dual is empty - which can happen in 9i and before (in 10g with fast dual - unlikely)

Re: The Marshal

2011-02-14 09:36 • by Nagesh
337599 in reply to 337597
tkyte:
read the code. resp is defaulted to 0.

if(rs.first()) resp = rs.getDouble("result");

If there is a row, it gets a value, otherwise it leaves resp alone.

and then returns it.

The original poster got it right - it returns 0 if dual is empty - which can happen in 9i and before (in 10g with fast dual - unlikely)


Stop faking. You're not real Mr Tom Kyte, are you? Unless he's a namesake of yours.

Re: The Marshal

2011-02-14 09:41 • by Smitty
There's nothing I hate worse than random abbreviations in variable names. Why 'String quer = null'? Is 'String query = null' simply too much to type? I see this kind of thing all the time.

Re: The Marshal

2011-02-14 09:47 • by dr dirsa (unregistered)
Actually the problem is that they are using double datatype as amount and they have found out that using sql seem to return the rigth value.


Have had the same problem with c++, there is no round function, had serious temptation to use oracle sql as well.

Re: The Marshal

2011-02-14 09:51 • by Cantabrigian
337606 in reply to 337603
Smitty:
There's nothing I hate worse than random abbreviations in variable names. Why 'String quer = null'? Is 'String query = null' simply too much to type? I see this kind of thing all the time.


Hear, hear. Example: the (fortunately now obsolete) C/UNIX "creat()" function. Why? Who thought that was a good idea?

Re: The Marshal

2011-02-14 09:52 • by anon (unregistered)
337607 in reply to 337603
Smitty:
There's nothing I hate worse than random abbreviations in variable names. Why 'String quer = null'? Is 'String query = null' simply too much to type? I see this kind of thing all the time.


Ugh, tell me about it. I know someone who, I am not making this up, uses an automated script to get rid of vowels in his identifiers. I gss thr s vwl shrtg r smthng.

Re: The Marshal

2011-02-14 09:56 • by SG_01 (unregistered)
TRWTF is that they directly put the variables into the query. They should have at least used named variables *nods*

Re: The Marshal

2011-02-14 09:58 • by dpm
337610 in reply to 337606
Cantabrigian:
Example: the (fortunately now obsolete) C/UNIX "creat()" function. Why? Who thought that was a good idea?
http://en.wikiquote.org/wiki/Kenneth_Thompson

Ken Thompson was once asked what he would do differently if he were redesigning the UNIX system. His reply: "I'd spell creat with an e."

Re: The Marshal

2011-02-14 10:05 • by Severity One
This reminds me of a developer who used to do everything in Oracle. This was a different developer from the one who did everything in C.

Once, I had to replace her code to do 128-bit DES3 encryption (yes, that's not a typo) by Java code, which was quite an interesting challenge, especially so because DES encryption is usually 64-bit (DES) or 192-bit (DES3). This was something like, DES2?

Re: The Marshal

2011-02-14 10:07 • by Severity One
337612 in reply to 337603
Smitty:
There's nothing I hate worse than random abbreviations in variable names. Why 'String quer = null'? Is 'String query = null' simply too much to type? I see this kind of thing all the time.

It was actually meant to be 'queer'. You know, as in 'strange'.

Re: The Marshal

2011-02-14 10:08 • by Shorel
They used Oracle for BigNum support.

TRWTF is the conversion to double...

Re: The Marshal

2011-02-14 10:10 • by anon (unregistered)
337614 in reply to 337610
dpm:
Cantabrigian:
Example: the (fortunately now obsolete) C/UNIX "creat()" function. Why? Who thought that was a good idea?
http://en.wikiquote.org/wiki/Kenneth_Thompson

Ken Thompson was once asked what he would do differently if he were redesigning the UNIX system. His reply: "I'd spell creat with an e."


Wait for it... wait for it... he already did!

Re: The Marshal

2011-02-14 10:10 • by frits (unregistered)
337615 in reply to 337603
Smitty:
There's nothing I hate worse than random abbreviations in variable names. Why 'String quer = null'? Is 'String query = null' simply too much to type? I see this kind of thing all the time.

Who hasn't done something like this?

Re: The Marshal

2011-02-14 10:12 • by Coyne
(evil laugh) Layers!!!! (even more evil laugh) We MUST have MORE layers!!!!

Re: The Marshal

2011-02-14 10:13 • by Smitty
337617 in reply to 337615
frits:
Smitty:
There's nothing I hate worse than random abbreviations in variable names. Why 'String quer = null'? Is 'String query = null' simply too much to type? I see this kind of thing all the time.

Who hasn't done something like this?


Me.

Re: The Marshal

2011-02-14 10:14 • by Coyne
337618 in reply to 337603
Smitty:
There's nothing I hate worse than random abbreviations in variable names. Why 'String quer = null'? Is 'String query = null' simply too much to type? I see this kind of thing all the time.


He had to abbreviate it, because he was afraid "query" was a reserved word.

Re: The Marshal

2011-02-14 10:21 • by dalv
This article has made my day !!! :))

Re: The Marshal

2011-02-14 10:28 • by boog
When I read the code snippet, in my mind I saw all of the townsfolk locking their doors and slamming their shutters as Marshall Eli stands in the middle of the town crossroads.

Re: The Marshal

2011-02-14 10:34 • by Mark (unregistered)
337623 in reply to 337597
tkyte:
read the code. resp is defaulted to 0.

if(rs.first()) resp = rs.getDouble("result");

If there is a row, it gets a value, otherwise it leaves resp alone.

and then returns it.

The original poster got it right - it returns 0 if dual is empty - which can happen in 9i and before (in 10g with fast dual - unlikely)


Would rs.first() be true if dual contains no rows?

Re: The Marshal

2011-02-14 10:41 • by - (unregistered)
Using doubles for calculations on monetary amounts!? At least there was a attempt to close the connection in a finally.

Re: The Marshal

2011-02-14 10:45 • by someone (unregistered)
wow, so there's and Exception... catch it, print the stack trace and return 0.

Re: The Marshal

2011-02-14 10:51 • by Steve The Cynic
337626 in reply to 337614
anon:
dpm:
Cantabrigian:
Example: the (fortunately now obsolete) C/UNIX "creat()" function. Why? Who thought that was a good idea?
http://en.wikiquote.org/wiki/Kenneth_Thompson

Ken Thompson was once asked what he would do differently if he were redesigning the UNIX system. His reply: "I'd spell creat with an e."


Wait for it... wait for it... he already did!

I dunno, maybe he meant, like, at the end.

fd = crate("fred.txt", 0664);

Re: The Marshal

2011-02-14 10:55 • by foo (unregistered)
337628 in reply to 337605
dr dirsa:
Have had the same problem with c++, there is no round function

Yeah, if only there was a way to call plain old C functions like round() from C++. I guess you need a multi-layered OOP framework for this ...

Re: The Marshal

2011-02-14 11:16 • by Neo (unregistered)
Obviously, TRWTF is not putting whitespace around binary operator ;)

return cost - discount;

Re: The Marshal

2011-02-14 11:36 • by @Deprecated
He simply strung up the code and put it out of its misery, replacing the entire body with a simple return cost-discount;.


I was sure this was going to end with:

put it out of its misery, by erasing the out dated, rogue application from the network.

Re: The Marshal

2011-02-14 11:37 • by jasmine2501
337632 in reply to 337628
Joe client is gonna be pretty pissed off when he finds out you 'rounded off' his MONEY.

This could have been done in an attempt to get proper BCD data types to be used in the calculation, but there's nothing telling the database to do it that way either.

Re: The Marshal

2011-02-14 11:48 • by zdux (unregistered)
Avoiding some sort of floating point error?
Or keeping consistent floating math?
Or maybe it evolved from something more monstrous...

Actually I just kicked back some code last week that used a temp table to filter some data.

Re: The Marshal

2011-02-14 11:49 • by martiert (unregistered)
The reason for using a database for subtraction, addition etc. is of course quite clear. If theyr definition of subtraction changes in the near or far future, a simple change in the database will solve all problems, while the job of going through each and every file to fix the problem would require quite a lot of work.

Re: The Marshal

2011-02-14 11:57 • by Spike (unregistered)
They could also ask it to Wolfram Alpha and then parse the returning webpage :-)

http://www.wolframalpha.com/input/?i=5-7

Captcha veniam

Re: The Marshal

2011-02-14 12:00 • by Sean Inglis (unregistered)
337636 in reply to 337579
These things are fun, but it's really just another example of a project that ran out of time or ambition or direction.

Speculation, but once-upon-a-time at the start of the project, somebody decided the didn't want business logic in the GUI (is good!)

Someone else agreed, and someone else said they should stick it in a nice stored procedure, because that can be reused, and it's sitting next to the data we'll use for the calculation and we have development resource for it, and blah, blah, blah, fucking blah.

Anyway. The developer in question wrote in in such a way as to prove the route - the GUI can talk to the DB, there are no firewall or permission problems, and they can get back the magic scalar value as required.

I'd follow exactly this approach rather than spend time chasing down infrastructural problems and getting bit on the arse later.

But the calculation never was more complicated, or the vast reusable enterprise calculation engine was never written, or the developer moved on and nobody cared enough.

But I'd guess the developer was *right*.

Re: The Marshal

2011-02-14 12:03 • by Ollie Jones (unregistered)
Get with the enterprisey times!
Do it in the cloud!
Use Google Calculator!

Re: The Marshal

2011-02-14 12:03 • by frits
I would replace this with a call to a local instance of Excel. Perhaps I'd be even more creative and use a JavaScript ScriptEngine to evaluate the string.

Re: The Marshal

2011-02-14 12:04 • by Paul (unregistered)
337640 in reply to 337579
There's plenty of optimisation opportunities before you need to do the calculation client side! Surely he would have done better to get in a database consultant who could have helped tune that query...?

Re: The Marshal

2011-02-14 12:04 • by Pytry (unregistered)
337641 in reply to 337634
martiert:
The reason for using a database for subtraction, addition etc. is of course quite clear. If theyr definition of subtraction changes in the near or far future, a simple change in the database will solve all problems, while the job of going through each and every file to fix the problem would require quite a lot of work.


2 - 2 == 5

Re: The Marshal

2011-02-14 12:11 • by hoodaticus
Where to begin? Using SQL for addition (when the processor supports it natively), breaking standards when naming class level variables (see: dbm), and setting a local object reference to null RIGHT BEFORE the fucking function exits.

Who do I have to kill?

Re: The Marshal

2011-02-14 12:31 • by hoodaticus
337645 in reply to 337639
frits:
I would replace this with a call to a local instance of Excel. Perhaps I'd be even more creative and use a JavaScript ScriptEngine to evaluate the string.
ROFLMAO

Re: The Marshal

2011-02-14 12:34 • by hoodaticus
337646 in reply to 337633
zdux:
Avoiding some sort of floating point error?
Or keeping consistent floating math?
Or maybe it evolved from something more monstrous...

Actually I just kicked back some code last week that used a temp table to filter some data.
There's nothing wrong with that use of temp tables (at least not as you stated it). I turned a 10.5 hour-long query into an 8 second one by unrolling nested WHERE NOT EXISTS with a temp table.

This was in commercial software that we bought the source for, btw.

Re: The Marshal

2011-02-14 12:42 • by boog
337648 in reply to 337639
frits:
I would replace this with a call to a local instance of Excel. Perhaps I'd be even more creative and use a JavaScript ScriptEngine to evaluate the string.

Why not integrate it into the workflow?

Make calculateCostSQL a "Human Task", so whenever invoked an automated email containing the parameters is sent to a Senior Arithmetic Analyst, who performs the subtraction (using a database), pulls up the Subtraction Response form, and submits the difference, which is then placed in the Cost Calculation queue for the application to receive.

Sure, it needlessly slows processing time, but it evenly distributes the work over more company resources.
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment