BrainDump
  Home arrow BrainDump arrow Page 3 - Working with Code Libraries
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
BRAINDUMP

Working with Code Libraries
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2007-08-02

    Table of Contents:
  • Working with Code Libraries
  • 4.1 Externalizing Business Rules with NxBRE
  • Using NxBRE
  • Creating rules for the Inference Engine
  • Implementing the engine

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Working with Code Libraries - Using NxBRE


    (Page 3 of 5 )

    A business rule generally consists of a condition followed by one or several actions executed if the condition is met.

    The following is a classical set of business rules for computing sales discount:

    Rule #1
       The discount for a customer buying a product is 5.0
       percent if the customer is premium and the product is
       regular.

    Rule #2
       The discount for a customer buying a product is 7.5
       percent if the customer is premium and the product is
       luxury.

    Rule #3
      
    A customer is premium if his spending has been min
       5000 Euro in the previous year.

    We’ll see how these rules translate to a rule base momentarily. A rule base is a file that contains the definitions of several business rules. NxBRE uses these rule bases to control its processing.

    Creating rule bases for the Flow Engine

    NxBRE does not provide any facility for editing rules for the Flow Engine. Since the rules expressed in XML are similar to traditional flow-control programming, using an XML editor such as jEdit (Figure 4-1) that supports schema validation and offers contextual element insertion is generally sufficient. 

                     
    Fgure 4-1.  Using jEdit to create flow-control rules

    The example Rule #1 shown previously can be expressed this way:

      <Logic>
        <If>
         
    <And>
              <Equals leftId="CLIENT_RATING" rightId="PREMIUM_RATING" />
              <Equals leftId="PRODUCT_TYPE" rightId="REGULAR_TYPE" />
         
    </And>
          <Do>
              <Integer id="DISCOUNT_PERCENT" value="5" />
          </Do>
        </If>
      </Logic>

    The Flow Engine contains an HTML-rendering engine that offers a convenient way to navigate through rules and read them transformed into pseudocode. Figure 4-2 shows one of NxBRE’s unit test rule files transformed in such a manner.


    Figure 4-2.  HTML pseudocode rendering of flow-control rules

     

    To organize big rule bases, it is a good idea to leverage the notion of a rule set that is supported by the Flow Engine. It allows you to group several rules into a named group that gets evaluated on demand.

    More BrainDump Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Windows Developer Power Tools," published...
     

    Buy this book now. This article is excerpted from chapter four of Windows Developer Power Tools, written by James Avery and Jim Holmes (O'Reilly, 2006; ISBN: 0596527543). Check it out today at your favorite bookstore. Buy this book now.

    BRAINDUMP ARTICLES

    - Introduction to Office Live Workspace
    - Using MS Excel for One-way Analysis of Varia...
    - Comparing Data Sets Using Statistical Analys...
    - Import Blogger Posts into WordPress Using Wi...
    - Download WordPress from an FTP Server and Ru...
    - Install and Run WordPress in XAMPP Local Host
    - What Windows 7 Brings to the Table
    - Virtualization and Sandbox Detection
    - Advanced Firebug Techniques in Windows XP Ho...
    - Editing CSS with Firebug in Windows XP Home
    - Using Firebug in Windows XP Home
    - Migrating to Exchange Server 2007
    - Using System Restore on a Non-Bootable PC
    - Finding Logged on Users and More Scripting S...
    - Developing Macro Commands in MS Excel





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek