Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

This "manager" is 70+ yrs old and a math genius. We were tasked with creating a web application. He loves SQL and stored procedures. He first created this in MS access. For the web app I had to take his DB migrate to SQL server. His first thought was to have a master stored procedure with a WAITFOR Handling requests from users. I eventually talked him out of that and use asp.net mvc. Then eventually use the asp.net membership. Now the web app is a mostly handles requests from the pages that is passed to stored procedures. It is all stored procedure driven. The business logic as well.

What are the best arguments for not having the business logic not all in stored procedures?? How should I deal with this?? I am giving an abbreviated story of course. He is a genius part owner of the company all the other owners trust him because he is a genius. and quoting -"He gets things done. old school".

share|improve this question
3  
Can you explain (to him) why "He complains why my code is bad cause his test driver stored procedure simulates over 100 users with no issue." is true or not? If that works with 100 users, why does your implementation only scale to 25? –  Peter K. Mar 16 '11 at 15:35
4  
Why do you have a connection per user? Even if all of the business logic is in sprocs you should always open a connection, call the sproc, retrieve any data you need and close the connection. Keeping connections hanging around in .NET is contrary to the way it is designed to work. –  Ant Mar 16 '11 at 15:54
add comment

4 Answers

Step 1. Admit that it's your code.

Step 2. Stop all work on relevant, useful functionality and start digging in to the performance problem. Seriously. If everyone trusts the genius, then you can either go with the flow or suffer the stress of arguing with everyone.

Step 3. Figure out how to measure the performance problem. It's not easy to find the bottleneck that makes 25 sessions in asp.net mvc. But you have to find the problem.

Step 4. When you find the problem, you can now present facts to your genius friend that will show precisely what the root cause is.

Here's what's going to happen.

Everything that's not a stored procedure is suspect. You have to measure everything you can measure until you have eliminated all differences between the "test driver stored procedure simulates" and the real world. All the differences. All of them.

Once you have proven that the stored procedures are the root cause, be prepared for what will happen next.

You'll be told to build the entire thing in Access because it works better than SQL/Server.

Guess what the next step will be?

Building it in Access, and going through the entire performance measurement exercise to prove that Access is slower that SQL/Server.

Then -- and only then -- will you be able to propose a better solution.

You are providing one-on-one hand-holding education. It's slow and expensive for the company. But it's the only way to educate a genius.

share|improve this answer
    
Lol, don't geniuses come in different flavors? Some more mad than others ... –  Job Mar 16 '11 at 15:48
    
Yes I agree with the problem is mine and I need to really dig to to see the issue. But after dealing with this since november of last year my knee jerk reaction is that "my code" is not doing anything. Wrong but ... –  Joe Mar 16 '11 at 15:55
    
@Joe: It isn't doing anything wrong. But you have to prove it, sadly. Or. By stopping all forward progress, you may educate other folks in the company that the genius needs a new assignment. –  S.Lott Mar 16 '11 at 17:05
add comment

Unless they are horribly written, the stored procedures are not the source of your performance problem. When it comes to assembling data into business objects, stored procedures smoke any middle tier solution because they do not incur IPC latency. In my humble opinion, the problem lies between your database access and presentation code.

share|improve this answer
add comment

Never heard of connection pooling?

http://msdn.microsoft.com/en-us/library/8xx3tyca.aspx

He complains why my code is bad cause his test driver stored procedure simulates over 100 users with no issue.

Well, he proved it not HIS Code. Prove it not yours! You can learn a thing or two from this guy.

share|improve this answer
    
blogs.msdn.com/b/kaevans/archive/2009/04/09/… I create and destroy the datacontext for each repository class. I also use auto fact that creates 1 repository class then so therefore datacontext which is destroyed, –  Joe Mar 16 '11 at 17:24
add comment

Why on earth would you not want to put the business logic in stored procedures, especially when the rest of the application uses them? They are easier to performance tune, they are easier to manage and they are in the database (And the database metadata), so you can figure out what impact a proposed database structural change will have easily.

share|improve this answer
    
Back in the days when I had to write web systems with classic ASP, this was my team's approach. Business logic in stored procedures and VBScript just for the presentation layer. The systems were all fast. As an added bonus, writing 2,000 line queries was a good way to learn SQL. –  Ant Mar 17 '11 at 9:03
    
I really have to disagree with you. The are very good reasons to use c# as opposed to stored procedures. These arguments can found on the internet. –  Joe Mar 18 '11 at 4:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.