Hi Nick,

*My* answer to your first question is: "it depends". I'll share my opinion
on this, but you should certainly consider other sources for more input on
this (and there are many other opinions that may not agree :)

In nearly all (99.9%) cases, I believe that attributes and rules (a.k.a..
behaviors) should be encapsulated in objects. From there, I think its
absolutely fair game to externalize _configuration_ of your objects into
xml, property files, or some other persistent store. If users need to
'change' the rules, let them change configuration, or let substitute another
self-contained, independent, *component*. In this scenario, I see regex's as
configuration parameter's. In a JavaBean's environment, I would quite likely
register this type of property as "expert". On the other hand, if user's
want to control whether a property on a form is required or not, I would let
them, ableit indirectly, specify another component that follows that
behavior. That way, they don't need to deal with code, ever.

This, in my mind is an essential abstraction that object-orientation has
been shooting at, quite successfully, for several years. 

In very rare cases (.1%) where encapsulating attributes and rules in objects
doesn't fit the bill, I -*might* consider implementing the interpreter
pattern. This, however, increases the complexity (for developers and users)
many degrees. If you are interested in that route, I would investigate Bruce
Eckel's example  in "Thinking In Patterns" at mindview.net.

Regards,
Levi

> -----Original Message-----
> From: Nick Afshartous [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 25, 2001 8:24 AM
> To: [EMAIL PROTECTED]; Cook, Levi
> Subject: RE: server-side, java-based validation rules for struts..
> 
> Cook, Levi writes:
>  > IMHO, expressing rules using first class Java objects  *can* be just as
>  > flexible as defining rules in an XML file. 
>
> Thanks Levi for pointing out that a property editor could be used.
> Could one also add new rules and attributes dynamically with a
> property editor ?
> 
> Maybe the trickiest part for the users would be to learn the
> syntax for rule expressions.  In particular how to refer
> to object attributes within a rule.  
> -- 
> 
>       Nick
> 

Reply via email to