somehow you need a way to store a "rule"
this isn't easy

there's a few things to consider....
simple things like string length are easy enough, store in a db or xml
things like.
"namespace.classname.propertyname", minlength, maxlength, allownull

then you have to consider the combination of 2 or more properties needed to
determine if something is valid.
example, date ranges... startdate must be earlier than enddate..etc..

if you can find or come up with a db or xml structure to store all the info
needed for a validation rule, then you should be all set....

the hard part comes when you have a new rule that doesn't quite fit what you
need...you end up with finding a way to group rules together and apply more
rules to the group as a whole...hints of recursion...

then there are more rule structures to consider where the value of one
property on a object is used as part of the validation rule against the
combination of multiple other properties..ex: a date range check for
start/end date, but the ragne check depends on which person's calendar you
are working with...

it stops being fun after a while.. :)


-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] Behalf Of Paul Cowan
Sent: Monday, February 12, 2007 12:18 PM
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] Business Rules


Hi,
I have seen that before, but what I am trying to avoid is having the rules
hard coded into the code.  It means a code change and recompile to every
rule change.I guess I am looking for xml configuration.  I know there is
http://www.agilepartner.net/oss/nxbre/.  I think it is written in .NET 1.1
(we are using 2.0) and may seem a bit heavy for what I am trying to achieve.

[EMAIL PROTECTED]



> Date: Mon, 12 Feb 2007 12:05:31 -0500> From: [EMAIL PROTECTED]> Subject: Re:
[ADVANCED-DOTNET] Business Rules> To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM> >
you may want to look here:> http://www.lhotka.net/cslanet/download20.aspx> >
and poke around the base classes to see how the validations are setup....i>
really like it.> > basically each object keeps it's own internal list of
"Broken Rules", a> public property "IsValid" returns "BrokenRules.Count =0">
> in all your property Set statments, test for the rule being broken and if
it> is broken add it to the internal list, if the rule is not broken, make
sure> it's not in the internal list.> > there's a BrokenRule struct in there
too that helps expose the validation> message & other error info to calling
code.> > > > -----Original Message-----> From: Discussion of advanced .NET
topics.> [mailto:[EMAIL PROTECTED] Behalf Of Paul
Cowan> Sent: Monday, February 12, 2007 12:01 PM> To:
ADVANCED-DOTNET@DISCUSS.DEVELOP.COM> Subject: [ADVANCED-DOTNET] Business
Rules> > > Hi,> Not sure if everyone has forgiven me for my last rant which
was pretty wrong> :-) but I am looking for some advice to what I guess is a
pretty common> problem.We are developing an application that will have a lot
of business> rules that will change quite a lot during development. We have
a domain> model with aggregation used quite a lot. Now the most advanced I
have ever> got with this in the past is to have my POCO implement an
IValidate> interface and have the rules hard-coded into a validate method.
As I am> sure you will agree this is a very inflexible approach.> > Does
anyone know a better way of approaching this time honoured problem?> Cheers>
Paul> ===================================> This list is hosted by
DevelopMentor® http://www.develop.com> > View archives and manage your
subscription(s) at http://discuss.develop.com> >
===================================> This list is hosted by DevelopMentor®
http://www.develop.com> > View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to