User:Fairguy~enwiki/Best Practices Part2

Business Rule Mining - Best Practices (cont'd)
8. Rule Mining Workflow

Enterprise rule mining is usually a multi-step process involving practitioners with disparate skill sets – including consultants, developers, architects, analysts, and subject matter experts. Often key personnel will be distracted by other projects and it is therefore crucial that a common workflow be defined and documented.

Following the guidelines provided further in this document, a high-level workflow may appear as:

Figure 3: Sample Rule Mining Workflow

Each step should be defined in detail, following an adopted methodology, project scope and constraints and rule mining technology usage. There may be multiple iterations of the first few steps until the rules are in an approved, final format.

Rule Mining Steps
9. Mining of Candidate Rules

At this point rules are mined from the application artifacts mapped to the scope of the business processes identified in previous steps. Rule mining tools help you assure that excluded artifacts are not included in scope by enabling the organization of an application into sub-groupings. Rules will be mined for a sub-grouping and not for the entire application.

The specific rule mining approach taken is primarily driven by application patterns and the desired output.

Top-Down Approach

A top-down, or process-oriented approach starts from an examination of the user interface in an online application, or from the job flow in a batch application.

In an online application, a transaction may be invoked by a user selecting a menu option or entering a value to the screen. The fields that define the message or event that is sent from the screen to the interfacing application are identified. Each field in the triggering message may be considered a seed field for rule mining.

Using a seed field as a starting point, all of the downstream data impacts to the field including all conditional permutations are documented. Each data transformation (move into another field or calculation), represents a candidate business rule to be captured.

Rule mining software tools assists in this task by visualizing a data impact path forward for each seed field to each point where it is either populated by new values or used as input to other fields via comparisons, value propagation and calculations. At each such point, the tool can be used to document the underlying business rules. Automated rule detection methods can also be applied to capture each screen field edit as a candidate rule.

In a batch application, the concept is similar. Part of a job flow, e.g. a JCL or group thereof that realizes a business process is identified, and all rules within individual programs relevant to that process are mined.

Figure 4: Top-Down Rule Mining

In Figure 4 above, note the format of the resulting "Derived Candidate Rules". Automatically detected from a Cobol program, they resemble its constructs, with variable names replaced by the Glossary definitions. These will later undergo review and transformation to a more businesslike form. While this example is demonstrated for a Cobol application, advanced mining tools may apply to a broad array of languages from PL/I and Natural to Visual Basic and Java.

Bottom-Up Approach

A bottom-up, or data-oriented approach starts from an examination of system outputs – data sent to files (both batch and online), screens and output messages (online only).

Following this approach, rules are captured by starting from an interesting data point and identifying all logic impacting that point. For example, an Order Discount field is impacted by discounts calculated upstream from it, depending on the customer's location of residence.

Figure 5: Bottom-Up Rule Mining

Rule mining technologies are particularly well suited to this approach. Through visual inspection or a repository query, data outputs of interest can be quickly indentified. Then, automated rule detection routines are able to capture a candidate rule for each statement that impacts the point of interest. Because of the pre-organization into contextualized sub-groupings mentioned above, the search results will be constrained by the subset of business processes deemed relevant for rule mining.

Inspection of relevant DBMS tables may also produce rules embedded in keys and any data rules for referential integrity and value constraints. Once all data points of interest have been covered, all application logic of interest oriented toward existing outputs has essentially been mined.

Hybrid Approach

A hybrid approach combines the two approaches described above:
 * The first step is a top-down oriented capture of the relevant transactions;
 * For each transaction, bottom-up rule mining is performed, including only data outputs that have not yet been already mined for another transaction.

The benefit of this approach is to extend the coverage of rule mining while avoiding repetition.

Relating to the examples shown in Figures 4 and 5 above, following a strictly top-down approach resulted in repetitive efforts for the Quantity and Price fields since they both traversed identical downstream data impacts. Coverage was also partial since not all of the rules for Customer Discount were discovered.

Let’s consider an extended case involving both Order Entry and Proposal Issuance processes. Adopting an exclusive bottom-up approach would have also resulted in repetition, mining rules for upstream data impacts that "hit" multiple outputs (e.g. customer discount rules). Using the hybrid approach, we would first mine rules from all outputs of the order transaction, then only outputs of the proposal transaction particular to it.

Figure 6: Hybrid Rule Mining

10. Candidate Rules Verification

At this point, after mining candidate rules from your application, verification and correction is a necessary step to ensure the correctness and completeness of the rules.

The candidate rules are examined for:

Accuracy Does each rule correctly reflect the underlying application behavior? If automated rule detection technology has been used, a rule at the point of interest (seed field) will be preceded by rules upstream from it, possibly with triggers, control conditions, and automatic rule set groupings. Each one of them (or a chosen subset) is reviewed for accuracy and corrections are made where needed, until the results are deemed satisfactory.

Redundancy Does a rule or rule set appear twice for the same application process? This can occur when rules are mined separately for two separate outputs that share upstream functionality. Or it can be a result of simple oversight like multiple team members inadvertently mining rules from the same code base. A rule attribute is used to mark duplication.

Another form of redundancy occurs when semantically identical rules were mined separately and with different names from different processes (e.g. Order Detail and Proposal). This will be dealt with in the next step, when you transform candidate rules to business rules format.

Completeness Beyond predefined exceptions, has all of the application functionality been covered? A rule coverage report, matching mined rule sources to overall sources, can provide the answer.

Relevance Can each mined rule be considered a candidate business rule? Although this is not yet the SME review step, there may be certain constructs that, upon inspection, are clearly irrelevant and should not be included in the scope of rules for review. Security verification rules, housekeeping routines and out-of-scope operations may all fall into this category. Indicate relevance on one of the rule attributes.

11. Transformation of Candidate Rules to Business Rules Format

In the previous steps, candidate rules have been mined and reviewed, reflecting legacy application behavior. These rules closely follow the application's procedural flow and operations.

A transformational step is now required, to convert candidate rules to actual business rules ready for review. This step is conducted either by application experts, rule architects, or subject matter experts. After review and conversion, the business rules captured reflect the current, as-is state to serve as a baseline or comparison to the target environment.

Reformatting to Business Rule Notation

If the candidate rules were constructed manually, they may already be in the chosen business rules format. In other cases, they may have been captured in a technical format (like cut and paste from source code) and will require some modification and regrouping.

If an automated rule detection tool was used, the resulting candidate rules may somewhat resemble business rules, by using the glossary definitions to place business names within rule names, data elements and controlling conditions. However, even after the rule verification step, most of the approved candidate rules will need to be adapted to conform to a chosen business rule notation.

Figure 7: Business Rule Transformation

Fact Modeling and Rule Normalization Due to their procedural nature, legacy applications tend to lock business logic into process-specific silos. However, true business rules are independent of process and should be maintained as such.

In our example, rules for the Order Detail Entry and Proposal Entry events have been separately mined and placed in Rule sets. Are they all unique? Upon further examination, most of the logic in them is identical by design. Analyzing the results from a business perspective, there is commonality between portions of any customer document – whether Order or Proposal.

From a tooling perspective, at this point it may make sense to switch over to a Business Rule Management System (BRMS), importing the mined rules from the rule mining tool as described in the Integration section below.

Using a BRMS or a visual modeling tool, a Fact Model reflecting the significant business entities and their interrelationships discovered in your existing applications is constructed. These will link to the mined business rules and serve as a baseline for the to-be rules model.

In our example, part of the Fact Model would be:

Once this is done, the business rules are normalized to represent the desired business level semantics:

…whereby the Customer Document Handling rules apply to both Orders and Proposals. Grouping and Sequencing

At this point, the generated rule grouping and sequencing are considered. One point of attention is the triggering relationships between rules and other rules and rule sets. Since candidate rules are often derived from a 3rd generation language application (like Cobol or PL/I), they are automatically sequenced in a procedural manner. Transformation to a declarative mode will eliminate procedural elements that are non-business in nature.

As shown in Figure 8 below, declarative relationships that reflect true business requirements will be modeled as triggers between rules and other rules or rule sets. In the majority of BRMS environments, a single rule may trigger multiple rules and rule sets, where the sequencing of each triggered rule or rule set is pre-compiled or resolved only at runtime.

Figure 8: As-is Business Rule Model (Event-driven)

Subject Matter Expert Review and Approval
Once mined rules have been transformed into business rules, they are handed over to subject matter experts (SMEs) and / or business analysts for review and approval.

Normally, SMEs will not make major changes to the rules at this point. Rule mining tools may include rule attribution capabilities to aid the SMEs and enable them to mark up the business rules as

•	Approved or rejected; •	Reclassified to another category; •	Annotated with additional information in textual description attributes.

Rule mining tools also often offer web portals with a functional focus on predefined SME activities. This can greatly accelerate the review and approval process.

12. Reports Production

Business rule reports are created in either hardcopy or digital formats. Rule mining tools produce reports and diagrams depicting detailed or summary rule information within your chosen context: hierarchy level, grouping, search result. These reports serve both as reference in the review steps and as documentation of record.

13. Integration with a Target Environment

Depending upon the adopted modernization strategy, integration requirements with other environments will vary.

Business Rule Development

Redevelopment with a business rule approach will typically leverage a BRMS authoring environment. These tools typically include XML import capabilities, which will be used to define an "as-is" business rule space, allowing rule developers to selectively re-use candidate rules deemed relevant for the target environment. This will provide valuable (and sometimes crucial) traceability from newly deployed rules back to their legacy origins.

Conventional Development

This approach typically involves building Java and .NET applications with comprehensive developer toolkits. Often, UML models will be used to define logical application views prior to actual code generation.

In these environments, mined business rules can be attached as behaviors in UML classes that leverage them. For example, an Order_Invoice class including Order_Discount as an attribute, may also include Calculate_Order_Discount as a class behavior. This behavior can be derived (and potentially imported) from the mined business rule performing the same function.

BPM

Business Process Management (BPM) tools enable process model creation and linkage to underlying rules and executable services. They also include the ability to define workflow rules (using BPEL) to govern the manual and automated transitions between activity nodes.

In this context, each activity node may be realized by business rules. Many-to-many relationships may exist between rule sets and supported activities. Populating BPM processes with their relevant mined "as-is" business rules can "close the loop" for business analysts and significantly advance IT / business alignment goals.

Requirements Management

Vendor offerings also include requirement tools that enable the definition of high level use cases, detailed flowcharts and activities for effective application development and management. In these environments, mined business rules can be imported and attached as either core requirements or as textual annotations to activity nodes.

SOA Enablement

Service enablement of existing applications involves code refactoring and deployment as service capsules. The rule mining step can be invaluable in locating fine-grained services within source code and serving up the required service components. For example, the results of automatic rule detection for the calculation of an order discount will include all code segments leading up to the final calculation. By creating a component slice with that code (and its dependents) only, the order discount calculation can be redeployed as a service.

14. Proactive Rules Management

We expect most applications to continue and maintained for many years into the future. Having mined rules from them, it is crucial that they continue to be updated and kept synchronized with future application changes. Rule mining tools offer maintenance and management capabilities, including


 * Automatic alignment of rules with their original code segments even when they have moved as a result of overall source code changes;
 * Audit trails for manual rule changes;
 * "Changer" routines allowing for individual or mass changes, post- rule mining.

Conclusion
A well-defined approach to business rule mining will allow for business contextualization early on in the process. Not only will the contextualization step help frame mined rules correctly, it will also reduce the rule mining investment to focus only on critical and dynamic business processes of interest. Regardless of the application modernization strategy adopted, the best practices and tool-assisted approaches described here will help you achieve your goals at a lower cost, with less repetition and higher quality results.