Where do business rules belong... OCP and SPs

From: Yaron Bental (bentalcy_at_yahoo.com)
Date: 01/19/04


Date: 18 Jan 2004 20:38:36 -0800

Hi

Being an OO follower I believe, and I know a few other do too,
business rules belong in the business tier, we all know the reasons.
With that habit in mind and in practice I set some time this week to
improve performance on a very slow page in one of the apps my team is
responsible for. I knew I have to touch a set of stored procedures and
in my mind I thought I wanted to move all the business rules captured
in the stored procedures back to where I think they belong.

No meter how hard I tried I could not move those rules into the middle
tier, performance would just degrade. Some of the stored procedures
filter (using some very complex business rules) through hundreds of
thousands of records. Simply moving this data into some classes and
filtering/calculating it there, just doesn't make sense, from
performance point of view.

Just to clarify one thing, most time I try to "live my life" without
breaking OCP (or SRP, LSP and the other important OO principals for
that matter) and it paid off a few time before. Obviously when you
code all this complex business rules in the a stored procedure at some
point or another, you either break OnceAndOnlyOnce or you might find
yourself using too much conditional logic.

I suspect that this piece of code is going to be extended in the
future. Those SPs will need to be revisited again, and code would need
to be added with some ugly and repeated "if else" statement.

Any thoughts would be greatly appreciated

Yaron



Relevant Pages