Re: Where do business rules belong... OCP and SPs

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


Date: 21 Jan 2004 16:29:10 -0800

Robert C. Martin <unclebob@objectmentor.com> wrote in message news:<unnr00dvr86nq8snkbj9gvu5dt79g4gij2@4ax.com>...
> On 18 Jan 2004 20:38:36 -0800, bentalcy@yahoo.com (Yaron Bental)
> wrote:
>
> >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.
>
> The back end server can do some things much much faster than the
> middle tier. That's just the nature of the beast. That means that
> there will be some things that you must delegate to the back end.
> However, that doesn't necessarily mean that you have to move too many
> business rules down there.
>
> First, try to limit the stored procedures to only those things that
> are slow. Then see if you can abstract any reference to business
> rules away from them, so that they become pure mechanism. The more
> you can view them as a toolkit of finely grained general purpose
> tools, the better.
>
> Clearly there will be some things that don't fit this mold, and you'll
> just have to put the rules down in the stored procedures. So be it.

Thanks very much for your input! Would you agree then, that one cannot
always conform to the OCP. IOW some business rules should live in the
sps (although we don't like it) at some point down the road i might
need to change existing code even just to extend behavior?



Relevant Pages

  • Re: Database Model - Class, objects and interaction
    ... Stored procedures should only be used as a last resort if you cant use ... I've not said that views shouldn't be created, only that they shouldn't be exposed as the interface to the database. ... But business rules can be more complicated than simply defining overdue invoices. ...
    (comp.object)
  • Re: Business rules in stored procs.
    ... > that no business rules should be described by TSQL. ... > rules belong in the middle tier. ... the business rules in the same technology and tier. ... and that stored procedures just tie your ...
    (microsoft.public.sqlserver.programming)
  • Re: No knowledge of the database?
    ... stored procedures are the worst way of enforcing business rules ... in the database using very few "stored procedures". ... Alfredo ...
    (comp.object)
  • Where do business rules belong... OCP and SPs
    ... business rules belong in the business tier, ... in the stored procedures back to where I think they belong. ...
    (comp.object)
  • Re: Where do business rules belong... OCP and SPs
    ... >business rules belong in the business tier, ... >in the stored procedures back to where I think they belong. ...
    (comp.object)