Seems like you got it Alex. Although the example you provided doesn't seem to "need" a rules engine, the basic idea is correct. Your java beans contain all the data required and your rules form your decision structure (all the algorithmic part).
I have found that to be the coolest thing about Rules technology. Once you get over that procedural programming hurdle, rules take the most complex part of an application out of code allowing for a far rapid rate of evolution and code reuse. Of course everyone in this list already knows that. :) [EMAIL PROTECTED] wrote: > Hello, > > Since the rules I am writing in Jess need to modify attributes of Java > objects and control the way the application (app server) is running, I need > to have most of the data on the Java side. If only because some of it will > be either stored in a database or displayed on the screen (HTML generation > from templates in WebObjects). > > The simplest seems to be to only have facts which are actually instances of > Java objects and that dynamically notify Jess. On the Jess side, I have the > rules which modify and sometimes create those objects. > > For example, an very basic state machine to handle the display: > > (defrule switchRule1 > (Session (readyToRun TRUE) (currentActionName "COMPLETER_CALLED") > (OBJECT ?x)) > => > (call ?x setCurrentStateName "UsingCompleter") > ) > > (defrule switchRule2 > (Session (readyToRun TRUE) (currentActionName "SCRIPT_SELECTED") (OBJECT > ?x)) > => > (call ?x setCurrentStateName "UsingScript") > ) > > (defrule switchRule3 > (Session (readyToRun TRUE) (currentActionName "ORDER_TEMPLATE_SELECTED") > (OBJECT ?x)) > => > (call ?x setCurrentStateName "EnteringOrder") > ) > > (defrule componentRule1 > (Session (currentStateName "UsingCompleter") (readyToRun TRUE) (OBJECT > ?x)) > => > (call ?x setLeftComponentName "CompleterComponent") > (call ?x setRightComponentName "OrdersComponent") > (call ?x setBottomComponentName "CommentComponent") > ) > > (defrule componentRule2 > (Session (currentStateName "UsingScript") (readyToRun TRUE) (OBJECT ?x)) > => > (call ?x setLeftComponentName "ScriptComponent") > (call ?x setRightComponentName "OrdersComponent") > (call ?x setBottomComponentName "CommentComponent") > ) > > (defrule componentRule3 > (Session (currentStateName "EnteringOrder") (readyToRun TRUE) (OBJECT > ?x)) > => > (call ?x setLeftComponentName "ScriptComponent") > (call ?x setRightComponentName "OrderEntryComponent") > (call ?x setBottomComponentName "CommentComponent") > ) > > Am I doing something "philosophically wrong" or is a it correct way to view > development with Jess? > > It is more or less as if my Java classes where only used to store data and > map the data to the screen, etc... And all the algorithmic part is handled > by Jess rules. > > Alex > -------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED] --------------------------------------------------------------------
