before I start filling up the first page of perhaps many pages of code with
if/then or switch:case buckets, I wanted to step back and see if there is a
better way...
I will have a table with up to 300 rules in it. Maybe more... In each Score
table there is a column which will refer to a domain specific table and
another table column that contains the property of that domain specific
object. IceCream is a domain and scoops is a property I want to compare
against. There are two other columns which have an operator (=,>,<) and a
value to compare against. And a score assigned to that rule. If
object.value > 100,000 scoops of ice cream, assign a score of 100.
Basically a rule will compare a value for an object which has already been
hydrated from the database and goes through the rule filter, which I have
yet to build. If object.value > target.value then assign score. Keep a
cumulative score as this object, with its various properties and property
values, as it drops through the logic filter.
I am trying to prevent an unwieldy control flow maze. Does anyone have
ideas? I have heard about control structures like the HybridDictionary but I
am having a difficult time imagineering that. I know what to do with an ice
cream cone, especially chocolate chip, but I don't know what to do with a
HybridDictionary object.
Maintanability of this engine would be important as well as the possibilty
of caching all the rules so that no database calls are required after the
service or executable is running. Thank you. -hazz 11 2587
Hi,
I'm not sure what your budget is, but a third party component like ILOG Rules
for .NET may do what you need <http://www.ilog.com/products/rulesnet/>
Unfortunately, ILOG tends to be on the expensive side.
Best regards,
Rodger
Sequence Diagram Editor - Draw sequence diagrams faster
<http://www.SequenceDiagramEditor.com>
hazz wrote: before I start filling up the first page of perhaps many pages of code with if/then or switch:case buckets, I wanted to step back and see if there is a better way... I will have a table with up to 300 rules in it. Maybe more... In each Score table there is a column which will refer to a domain specific table and another table column that contains the property of that domain specific object. IceCream is a domain and scoops is a property I want to compare against. There are two other columns which have an operator (=,>,<) and a value to compare against. And a score assigned to that rule. If object.value > 100,000 scoops of ice cream, assign a score of 100. Basically a rule will compare a value for an object which has already been hydrated from the database and goes through the rule filter, which I have yet to build. If object.value > target.value then assign score. Keep a cumulative score as this object, with its various properties and property values, as it drops through the logic filter.
I am trying to prevent an unwieldy control flow maze. Does anyone have ideas? I have heard about control structures like the HybridDictionary but I am having a difficult time imagineering that. I know what to do with an ice cream cone, especially chocolate chip, but I don't know what to do with a HybridDictionary object.
Maintanability of this engine would be important as well as the possibilty of caching all the rules so that no database calls are required after the service or executable is running. Thank you. -hazz
One thing you could do is to place your rules in a database. Each rule
consists of an XPath expression for the operand, and operator, the value you
compare against, and the score. Bring your data into your system and
serialize it into an XML document. Then, apply each of the Xpath queries to
the object, one at a time. If the query produces a result, you have a value
you can compare against. Apply the comparison and, if true, add the score
to your accumulated score.
This will work regardless of the data coming in, and your storage mechanism
can work for anything. Xpath queries are very powerful and you can
differentiate easily depending on the structure of the inbound document, so
that a query may match a value only if it is at a particular place in the
document, or anywhere in the document... up to you.
Total lines of code < 200. Highly flexible since you can add and delete
rules in the db at any time.
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"hazz" <gr*********@nospamcomcast.net> wrote in message
news:eA**************@TK2MSFTNGP12.phx.gbl... before I start filling up the first page of perhaps many pages of code with if/then or switch:case buckets, I wanted to step back and see if there is a better way... I will have a table with up to 300 rules in it. Maybe more... In each Score table there is a column which will refer to a domain specific table and another table column that contains the property of that domain specific object. IceCream is a domain and scoops is a property I want to compare against. There are two other columns which have an operator (=,>,<) and a value to compare against. And a score assigned to that rule. If object.value > 100,000 scoops of ice cream, assign a score of 100. Basically a rule will compare a value for an object which has already been hydrated from the database and goes through the rule filter, which I have yet to build. If object.value > target.value then assign score. Keep a cumulative score as this object, with its various properties and property values, as it drops through the logic filter.
I am trying to prevent an unwieldy control flow maze. Does anyone have ideas? I have heard about control structures like the HybridDictionary but I am having a difficult time imagineering that. I know what to do with an ice cream cone, especially chocolate chip, but I don't know what to do with a HybridDictionary object.
Maintanability of this engine would be important as well as the possibilty of caching all the rules so that no database calls are required after the service or executable is running. Thank you. -hazz
In message <eA**************@TK2MSFTNGP12.phx.gbl>, hazz
<gr*********@nospamcomcast.net> writes before I start filling up the first page of perhaps many pages of code with if/then or switch:case buckets, I wanted to step back and see if there is a better way...
Can the logic be expressed as a flowchart? I wrote a workflow/rules
engine for a previous employer based on that premise. The engine manages
a branching and joining structure of abstract rules with a single entry
point and a single termination point. There's an abstract Evaluate()
method on Rule like this:
public abstract bool Evaluate(object subject);
Developers subclass Rule and implement their own test, casting subject
to whatever it is the rule needs to evaluate. The subclass names and
configuration information for each subclass instance are stored in a
database and instantiated using reflection. Rule subclasses also know
(or more usually know how to calculate) the URL for the webpage which
can affect the outcome of the evaluation (i.e. if the rule is that a
project must have a budget defined, the ProjectBudgetDefinedRule knows
how to calculate the URL to the project budget entry page). Each rule
graph defined in the database is created as a stateless singleton. The
subject to be evaluated is run through the graph generating a memento of
the graph structure containing the evaluated state of the rules.
The memento is built of State classes and uses a voting mechanism to
determine whether a rule has been reached. Subclasses of Rule and State
are used to handle joining (AND) situations, so that JoinState evaluates
to completed if all directly preceding steps are completed. You can then
evaluate whether the entire process has completed and if not, which
steps are available to continue.
I used a web graphics package ( http://www.nwoods.com/) to put a
graphical flow chart representation on the front end so that users could
be walked through business processes by clicking on shapes on a flow
chart. I wrote a Windows Forms app to allow the rule graphs to be set up
using drag and drop.
It's not difficult, and it isn't a huge amount of code, but it does take
a fair bit of designing, and you need to be sure that what you are
trying to model rules for can be expressed in that way.
--
Steve Walker
I do a lot with XSLT for simple rules as well...
I know these projects aim at something like this, but have never used them: http://www.agilepartner.net/oss/nxbre/ http://sourceforge.net/projects/sdsre/
Good luck,
Wiebe
hazz wrote: before I start filling up the first page of perhaps many pages of code with if/then or switch:case buckets, I wanted to step back and see if there is a better way... I will have a table with up to 300 rules in it. Maybe more... In each Score table there is a column which will refer to a domain specific table and another table column that contains the property of that domain specific object. IceCream is a domain and scoops is a property I want to compare against. There are two other columns which have an operator (=,>,<) and a value to compare against. And a score assigned to that rule. If object.value > 100,000 scoops of ice cream, assign a score of 100. Basically a rule will compare a value for an object which has already been hydrated from the database and goes through the rule filter, which I have yet to build. If object.value > target.value then assign score. Keep a cumulative score as this object, with its various properties and property values, as it drops through the logic filter.
I am trying to prevent an unwieldy control flow maze. Does anyone have ideas? I have heard about control structures like the HybridDictionary but I am having a difficult time imagineering that. I know what to do with an ice cream cone, especially chocolate chip, but I don't know what to do with a HybridDictionary object.
Maintanability of this engine would be important as well as the possibilty of caching all the rules so that no database calls are required after the service or executable is running. Thank you. -hazz
Thank you for the idea Rodger! This looks like an interesting Microsoft
tools ecosystem solution. An immediate value of this info is to better frame
how my solution should be built; ie. user features, code integration, ease
of use, etc. thanks!
-hazz
"Rodger Constandse" <ro*************@effexis.com> wrote in message
news:Ge***************@tornado.socal.rr.com... Hi,
I'm not sure what your budget is, but a third party component like ILOG Rules for .NET may do what you need <http://www.ilog.com/products/rulesnet/>
Unfortunately, ILOG tends to be on the expensive side.
Best regards,
Rodger
Sequence Diagram Editor - Draw sequence diagrams faster <http://www.SequenceDiagramEditor.com>
hazz wrote: before I start filling up the first page of perhaps many pages of code with if/then or switch:case buckets, I wanted to step back and see if there is a better way... I will have a table with up to 300 rules in it. Maybe more... In each Score table there is a column which will refer to a domain specific table and another table column that contains the property of that domain specific object. IceCream is a domain and scoops is a property I want to compare against. There are two other columns which have an operator (=,>,<) and a value to compare against. And a score assigned to that rule. If object.value > 100,000 scoops of ice cream, assign a score of 100. Basically a rule will compare a value for an object which has already been hydrated from the database and goes through the rule filter, which I have yet to build. If object.value > target.value then assign score. Keep a cumulative score as this object, with its various properties and property values, as it drops through the logic filter.
I am trying to prevent an unwieldy control flow maze. Does anyone have ideas? I have heard about control structures like the HybridDictionary but I am having a difficult time imagineering that. I know what to do with an ice cream cone, especially chocolate chip, but I don't know what to do with a HybridDictionary object.
Maintanability of this engine would be important as well as the possibilty of caching all the rules so that no database calls are required after the service or executable is running. Thank ou. -hazz
Thank you Nick!
Without needing to get complicated, do you have a simple example of link
someplace that would help me frame the XPath query solution....ie. from the
db tables into the object, for which the accumulated score will be
generated?
I also need to visualize how this XML document will look and be used for
this rules engine solution.Any articles that come to mind?
Thanks for offering the XPath/XML way of thinking about this!
-hazz
"Nick Malik [Microsoft]" <ni*******@hotmail.nospam.com> wrote in message
news:04********************@comcast.com... One thing you could do is to place your rules in a database. Each rule consists of an XPath expression for the operand, and operator, the value you compare against, and the score. Bring your data into your system and serialize it into an XML document. Then, apply each of the Xpath queries to the object, one at a time. If the query produces a result, you have a value you can compare against. Apply the comparison and, if true, add the score to your accumulated score.
This will work regardless of the data coming in, and your storage mechanism can work for anything. Xpath queries are very powerful and you can differentiate easily depending on the structure of the inbound document, so that a query may match a value only if it is at a particular place in the document, or anywhere in the document... up to you.
Total lines of code < 200. Highly flexible since you can add and delete rules in the db at any time.
-- --- Nick Malik [Microsoft] MCSD, CFPS, Certified Scrummaster http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not representative of my employer. I do not answer questions on behalf of my employer. I'm just a programmer helping programmers. -- "hazz" <gr*********@nospamcomcast.net> wrote in message news:eA**************@TK2MSFTNGP12.phx.gbl... before I start filling up the first page of perhaps many pages of code with if/then or switch:case buckets, I wanted to step back and see if there is a better way... I will have a table with up to 300 rules in it. Maybe more... In each Score table there is a column which will refer to a domain specific table and another table column that contains the property of that domain specific object. IceCream is a domain and scoops is a property I want to compare against. There are two other columns which have an operator (=,>,<) and a value to compare against. And a score assigned to that rule. If object.value > 100,000 scoops of ice cream, assign a score of 100. Basically a rule will compare a value for an object which has already been hydrated from the database and goes through the rule filter, which I have yet to build. If object.value > target.value then assign score. Keep a cumulative score as this object, with its various properties and property values, as it drops through the logic filter.
I am trying to prevent an unwieldy control flow maze. Does anyone have ideas? I have heard about control structures like the HybridDictionary but I am having a difficult time imagineering that. I know what to do with an ice cream cone, especially chocolate chip, but I don't know what to do with a HybridDictionary object.
Maintanability of this engine would be important as well as the possibilty of caching all the rules so that no database calls are required after the service or executable is running. Thank ou. -hazz
Google 'c# rules engine'
Here's one that uses XML ... looks cool: http://www.dnzone.com/ShowDetail.asp?NewsId=600
"NxBRE is the first open-source rule engine for the .NET platform and a
lightweight Business Rules Engine (aka Rule-Based Engine)."
hazz wrote: before I start filling up the first page of perhaps many pages of code with if/then or switch:case buckets, I wanted to step back and see if there is a better way... I will have a table with up to 300 rules in it. Maybe more... In each Score table there is a column which will refer to a domain specific table and another table column that contains the property of that domain specific object. IceCream is a domain and scoops is a property I want to compare against. There are two other columns which have an operator (=,>,<) and a value to compare against. And a score assigned to that rule. If object.value > 100,000 scoops of ice cream, assign a score of 100. Basically a rule will compare a value for an object which has already been hydrated from the database and goes through the rule filter, which I have yet to build. If object.value > target.value then assign score. Keep a cumulative score as this object, with its various properties and property values, as it drops through the logic filter.
I am trying to prevent an unwieldy control flow maze. Does anyone have ideas? I have heard about control structures like the HybridDictionary but I am having a difficult time imagineering that. I know what to do with an ice cream cone, especially chocolate chip, but I don't know what to do with a HybridDictionary object.
Maintanability of this engine would be important as well as the possibilty of caching all the rules so that no database calls are required after the service or executable is running. Thank you. -hazz
Thank you for helping me think about this Steve. I like your object heiarchy
decomposition of the process. I also like how you attached the web graphics
package to this underlying model!
What is a memento? I think I get in a real basic sense what you are doing,
even if I can't (at the moment) connect all the dots to the implementation
level that I need.
Thanks again.
-hazz
"Steve Walker" <st***@otolith.demon.co.uk> wrote in message
news:za**************@otolith.demon.co.uk... In message <eA**************@TK2MSFTNGP12.phx.gbl>, hazz <gr*********@nospamcomcast.net> writesbefore I start filling up the first page of perhaps many pages of code with if/then or switch:case buckets, I wanted to step back and see if there is a better way...
Can the logic be expressed as a flowchart? I wrote a workflow/rules engine for a previous employer based on that premise. The engine manages a branching and joining structure of abstract rules with a single entry point and a single termination point. There's an abstract Evaluate() method on Rule like this:
public abstract bool Evaluate(object subject);
Developers subclass Rule and implement their own test, casting subject to whatever it is the rule needs to evaluate. The subclass names and configuration information for each subclass instance are stored in a database and instantiated using reflection. Rule subclasses also know (or more usually know how to calculate) the URL for the webpage which can affect the outcome of the evaluation (i.e. if the rule is that a project must have a budget defined, the ProjectBudgetDefinedRule knows how to calculate the URL to the project budget entry page). Each rule graph defined in the database is created as a stateless singleton. The subject to be evaluated is run through the graph generating a memento of the graph structure containing the evaluated state of the rules.
The memento is built of State classes and uses a voting mechanism to determine whether a rule has been reached. Subclasses of Rule and State are used to handle joining (AND) situations, so that JoinState evaluates to completed if all directly preceding steps are completed. You can then evaluate whether the entire process has completed and if not, which steps are available to continue.
I used a web graphics package (http://www.nwoods.com/) to put a graphical flow chart representation on the front end so that users could be walked through business processes by clicking on shapes on a flow chart. I wrote a Windows Forms app to allow the rule graphs to be set up using drag and drop.
It's not difficult, and it isn't a huge amount of code, but it does take a fair bit of designing, and you need to be sure that what you are trying to model rules for can be expressed in that way.
-- Steve Walker
Thank you. I think that is the same rules engine that Wiebe just mentioned
in the preceding response....and I am looking at that now. Thanks for
replying! -hazz
<ja*****@texeme.com> wrote in message news:42**************@texeme.com... Google 'c# rules engine'
Here's one that uses XML ... looks cool:
http://www.dnzone.com/ShowDetail.asp?NewsId=600
"NxBRE is the first open-source rule engine for the .NET platform and a lightweight Business Rules Engine (aka Rule-Based Engine)." hazz wrote: before I start filling up the first page of perhaps many pages of code with if/then or switch:case buckets, I wanted to step back and see if there is a better way... I will have a table with up to 300 rules in it. Maybe more... In each Score table there is a column which will refer to a domain specific table and another table column that contains the property of that domain specific object. IceCream is a domain and scoops is a property I want to compare against. There are two other columns which have an operator (=,>,<) and a value to compare against. And a score assigned to that rule. If object.value > 100,000 scoops of ice cream, assign a score of 100. Basically a rule will compare a value for an object which has already been hydrated from the database and goes through the rule filter, which I have yet to build. If object.value > target.value then assign score. Keep a cumulative score as this object, with its various properties and property values, as it drops through the logic filter.
I am trying to prevent an unwieldy control flow maze. Does anyone have ideas? I have heard about control structures like the HybridDictionary but I am having a difficult time imagineering that. I know what to do with an ice cream cone, especially chocolate chip, but I don't know what to do with a HybridDictionary object.
Maintanability of this engine would be important as well as the possibilty of caching all the rules so that no database calls are required after the service or executable is running. Thank ou. -hazz
In message <Op*************@TK2MSFTNGP15.phx.gbl>, hazz
<gr*********@nospamcomcast.net> writes What is a memento?
It's a pattern usually used where you want to persist or serialize the
internal state of an object without breaking the object's encapsulation.
In this case it's the same idea but to a different end. Because the
individual rules are stateless with respect to the method call, it
represents the structure of the object graph and the state generated
within the scope of the call.
--
Steve Walker
Thank you..
"Steve Walker" <st***@otolith.demon.co.uk> wrote in message
news:GS**************@otolith.demon.co.uk... In message <Op*************@TK2MSFTNGP15.phx.gbl>, hazz <gr*********@nospamcomcast.net> writes
What is a memento?
It's a pattern usually used where you want to persist or serialize the internal state of an object without breaking the object's encapsulation. In this case it's the same idea but to a different end. Because the individual rules are stateless with respect to the method call, it represents the structure of the object graph and the state generated within the scope of the call.
-- Steve Walker This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: neblackcat |
last post by:
Would anyone like to comment on the following idea?
I was just going to offer it as a new PEP until it was suggested that
I post it here for comment & consideration against PEP 308.
I'm far...
|
by: Petre Huile |
last post by:
I have designed a site for a client, but they have hired an internet
marketing person to incrase their search engine ranking and traffic.
He wants to put extra-large fonts on every page which will...
|
by: Craig Cockburn |
last post by:
Hi
I'm aware of the use of robots.txt and the use of <META NAME="ROBOTS"
CONTENT="index,follow">
However, what would be more useful is to be able to control within a
page which elements of...
|
by: fivelitermustang |
last post by:
Essentially what the program needs to do is split apart a large group of
data and then it further splits apart the groups of data, etc...
For example, Level 0 starts off with a large array data....
|
by: Achilleus Mantzios |
last post by:
I made a modification on DBMirror.pl,
an addition in the slavedatabase.conf file,
and added another replication table "specialtables".
The goal was to have a way of controlling
when a row of...
| |
by: ammarton |
last post by:
Hello all...I'm a bit new to working with Macros in Access so forgive
me if the terminology I use is not accurate.
To preface this, basically I am using a form on a replicated database
so the...
|
by: Jason Shohet |
last post by:
I have 6 rules for a given 'time' value.
if (0 < iTime <= .5) {iFee = 17}
else if ( .5 < iTime <= 1) {iFee = 20}
else if...
else if...
yada yada
I don't want to code this in C#...
|
by: jmathesius |
last post by:
Can anyone recommend any articles or links that might explain the best
way of externalizing business rules? I'm on a development team that
goes through tons of work orders that are constantly...
|
by: hardieca |
last post by:
Hi,
I'd like to know if anyone knows of any resources detailing the best
practices of validating rules in the business tier and providing
helpful error messages to users in the UI tier. All the...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |