Wednesday, February 20, 2008

I’ve heard they’re a big pain to maintain

Completely unrelated (other than being annoying/disturbing) gold nuggets from Ogg and Wagga...
At David’s company, management wasn’t a big fan of the whole check-in/re-compile/re-deploy process. They felt that it had too many steps and took far too long to complete. Their organization needed to adapt to software changes - especially bug fixes - much faster. So, to address this problem, they thoroughly analyzed the development process and carefully tweaked it for efficiency. I’m just kidding. Actually, their solution was to pioneer a new methodology called “SQL Sentences”.
...
All told, these changes required developers to modifiy their code to look like this...

string sql;
// @SQLSentence=0x02f0
if ((bool)(Configuration.GetValue("UseHardcodedSQL")))
{
sql = "SELECT cust_name, cust_phone, cust_addr " +
" FROM customers WHERE cust_type='Active'";
}
else
{
sql = DataConnector.GetSQLSentence(0x02f0);
}
... and, of course, add that same query to the sql_sentences table. And, should there ever be a change to the query, maintain it in both the code and the gigantic script created the sql_sentences table and the production database.
Though David wasn't around when these changes were implemented, when he came onboard and heard the story he asked the Lead Developer if he'd ever heard of a Stored Procedure before.
“Yeah,” he replied, “but I’ve heard they’re a big pain to maintain.”


Money makes me feel dirty II by ~penguine145

U.S. banks said "quietly" borrowing $50 billion from Fed

NEW YORK (Reuters) - Banks in the United States have been quietly borrowing "massive amounts" from the U.S. Federal Reserve in recent weeks, using a new measure the Fed introduced two months ago to help ease the credit crunch, according to a report on the web site of The Financial Times.

The newspaper said the use of the Fed’s Term Auction Facility (TAF), which allows banks to borrow at relatively attractive rates against a wide range of their assets, saw borrowing of nearly $50 billion (25.6 billion pounds) of one-month funds from the Fed by mid-February.
The Financial Times said the move has sparked unease among some analysts about the stress developing in opaque corners of the U.S. banking system and the banks’ growing reliance on indirect forms of government support.


Also, Centipede has suggested a 6 Degrees of ExxonMobil game. Thoughts?

Oh, one other thing - Wagga has suggested this blog's name to be changed to b aab³ or B aab³ or something along those lines. Thoughts?

21 comments:

Ogg the Caveman said...

Hmm... it's worth a shot, but I don't know if it'll get as much participation as 6 Degrees of Casey Serin did in its heyday. The hate for EM just isn't as strong around here as it was for Casey.

Oh, and Murst!

Centipede said...

Sad SQL up there.

How can anyone hate any person more than the Exxon factor?

wagga said...

1) It's important to note that the "quietly buying up" story comes from a UK source.

2) I don't know much about recursion notation, but the cubish thing is meant as a shortcut reference - ie. EN or IAFF. (IAFF - What's that?)

Centipede said...

Sian says "Hi!" in a NSFW sort of way.

Akubi said...

Maybe it's just not as fun to hate Exxon?
We need a fun, new chew toy!
WTF happened to M. SINGH anyway? I'm not sure how he'd feel about The Church of the Subprime these days...
I've been reading that the UK and most of Europe is really into Obama.
Hi, Sian!

wagga said...

Speaking of the bush thing, don't forget to watch the total lunar eclipse tonight. Or was that the clinton thing?

wagga said...

Speaking of SQL & SP:

If you have one, & only one executable attacking the database server, you can put the business rules wherever you want to.

More than one executable sucking up to the server - putting the business rules in anything else but an SP is death by a thousand paper cuts.

Ogg the Caveman said...
This comment has been removed by the author.
Ogg the Caveman said...

I agree about the need to centralize business logic, and I agree that in some environments SPs are the right place to put it. However, there are exceptions.

For one thing, the available tools for managing changes to the database schema (of which SPs are a part) are shockingly primitive and hard to integrate with a broader SCM strategy/toolset. I deal with web applications which generally live on the server in source form. As long as we're just touching code, upgrading from any version to the latest is a simple matter of doing an svn update and waiting a minute. For each database schema change we also have to run a SQL script that applies the update, and that tends to dominate the upgrade time.

Last week I upgraded something like 50 copies of our core product across umpteen source code revisions and anywhere from 4-8 DB schema revisions. It took about a day and a half, and I botched one of them badly enough to require a restore from backups. I'd missed one upgrade script in the middle of the batch.

Now imagine how many more schema changes there would have been if the business logic had been implemented as stored procedures. Bear in mind the failure rate I described above -- and I like to think I'm more disciplined than the average developer. Bear in mind also that the tools for comparing databases are all some combination of expensive, much more primitive than free SCM systems, or miss stored procedure differences.

We used to use stored procedures a fair bit but found that they made upgrades too time consuming and that tracking down the problem when (not if, when) somebody fucked up an sproc change was just too painful.

Worse, suppose that we were supporting products installed on customer systems. Shops that do that tend to have a "no sprocs, period" policy because it's a hell of a lot harder to find out if any stored procedures got out of sync than it is to ask if the customer is running the latest version of some binary.

In situations where you have good DBA support and either have only a few copies of something or don't mind waiting a long time for upgrades to get applied, sprocs make sense. That describes a lot of traditional IT departments, but not the environment I work in.

I'd also argue that, when used as a general-purpose programming language and not for its narrow intended purpose of data manipulation, SQL is pretty much the worst imaginable tool for the job. Pretty much everything else in common use today is more expressive, has better error handling, comes with far better debugging tools, has infinitely better library support, and fits the typical programmer's mental model better. Doing non-trivial business logic in SQL is like using flat files where most people would use an RDBMS -- just because it's handy doesn't mean it's the right tool for the job.

I tend to think that enforcing data integrity is the job of the database, and business logic belongs elsewhere. If the same logic needs to be accessible to multiple programs, implementing it in some kind of server process that sits between those programs and the DB is often a better choice than trying to shoehorn it into SQL.

Akubi said...

@Wagga,
This seems to be another one of your Zen koans. Of the several books I've been reading lately, one of them happens to be this one my mom lent me _Eat, Pray, Love_ and for some reason you remind me of the guy at the Ashram from Texas who called Liz Gilbert "Groceries".
I did my spiritual shit as a Zendo student and such a lot earlier, but obviously I haven't come a long way baby or I'd be smoking Virginia Slims.
I am once again reminded of my parents visit this afternoon - when my stepdad noted _The Audacity of Hope_ lying about in one of my many piles of crap and he went on with his pro-Billary rant and stated that he finds it odd that given my gender I wouldn't support her. I don't give a rat's ass what gender, color, whatever someone is - essentially, I either like them or I don't. In addition, who would know who Hillary is if it weren't for Bill? Somehow we started deconstructing women in leadership and male ties and where Margaret Thatcher fits in which left us all slightly confused. My mom (who also happens to support Obama, but apparently doesn't say anything about it when I'm not around) was a hardcore women's lib sort in the early 70's reiterated my point that it doesn’t mean much if she’s elected via her last name, but also made a point of stating that it is quite different now than it was in her era and she *was* happy to see that. Thankfully (I guess) I grew up on Sesame Street and Mr. Rogers and didn’t see that era, but it looks pretty groovy in old movies.
@Ogg,
I'm perfectly fine with leaving business logic in the middle tier.

Akubi said...

@Ogg,
Why I hate cursors:
Why can't most programmers understand simple set-based logic - and if they can't, then why don't they deal with their f-ing cursor on the app side?
Actually, there is very good error handling available in SQL Server 2005, but _most_ programmers don't use it (never have, never will - they're lazy).
Ogg, you clearly are not one of those lazy non-error-handling performance-ignore-mode programmers, but there are a ton of them (and they're often Russian).

Ogg the Caveman said...

I understand the point some people make that for Clinton to get elected would be a major milestone. However, I think that voting for her because she's a woman is just as sexist as voting for her opponent because he's a man. For a woman to be elected President because she's a woman would only be a sign of progress for those who think that gender warfare is a necessary thing. I'm not one of those people.

That said, I don't get the feeling that gender is a big factor for most of her supporters. Most seem to think that she's the best candidate in terms of her positions, qualifications, and personality. While I don't agree with that, I can respect it a lot more than "we should vote for her because she's a woman".

Akubi said...

They currently have ballroom dancing on PBS and I want to vomit.

Anonymous said...

I wuz hear and din't understood most of it.

Ogg the Caveman said...

If you ever encounter this form of pathology, proceed with extreme caution. You have found either a bizarre and subtle bug or a vicious marauding style of programming. Quite possibly both.

Akubi said...

When will COBOL just go away for good?

Ogg the Caveman said...

They still teach it in the MIS program at $UNIVERSITY. There's still enough of it out there that one could make a career doing nothing but COBOL if one so desired.

NotAnOptimist said...

Re: sprocs
Extremely useful is used right. Ridiculously lethal otherwise. My team's use of them varies from project to project, depending on the developer.

Re: Billary
Some of you might enjoy today's shirt: http://www.shirtaday.com/

Ogg the Caveman said...

I once worked on a sadistical process control system implemented entirely as a set of stored procedures and triggers. The math, evaluation logic, routing, etc. -- all in SQL. Working on it was... interesting.

Akubi said...

Re: sprocs
Extremely useful is used right. Ridiculously lethal otherwise.


Like multiple cursors in a massive transaction? We had a few of those when I started here and it gives me a headache just thinking about them.

I'd be tempted to buy that T-shirt just to see my stepdad's reaction if I wore it the next time I see him.

Ogg the Caveman said...

@ Akubi:

Like multiple cursors in a massive transaction? We had a few of those when I started here and it gives me a headache just thinking about them.

The aforementioned sadistical process control system had some of that. It needed a 16 processor Sun box, and there came a time when that was no longer enough.