myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cosma Colanicchia" <cosma...@gmail.com>
Subject Re: Client Validation Design Discussion
Date Wed, 12 Jul 2006 11:07:58 GMT
It seems to me that both ways lead to inheritance :)

I think that an interface should be used, especially if the *only*
goal of an abstract base class would be defining those two abstract
methods.

This is also more flexible because multiple interfaces inheritance is
allowed: suppose you have a validator which already extends some
class, you port it into Tomahawk and you want to add javascript
validation... where you should put your abstract base class? You can
only put it on top of all the others (but all other classes in
hierarchy must also be abstract then) or wrap the last extending class
(losing identity). Ok, maybe it isn't a common situation.. anyway with
interface approach, you simple make the last class implements
IClientSideValidator. Do you see any drawback in interfaces?


Cosma


2006/7/12, Cagatay Civici <cagatay.civici@gmail.com>:
> Hi,
>
> I'm about to finish my work on the client validation and have faced with a
> design dilemma here.
>
> There are two method getJsFunction() and getParams() that must be
> implemented by extended validators so which design seem more convenient?
>
> * Using an IClientSideValidator which will be implemented by extended
> validators marking them capable of doing validation at client side.
>
> or
>
> * Using ValidatorBase class which is the parent of all extended validator
> and declare the two methods as abstract.
>
> I've chosen the abstract class instead of the validator although all the
> design patterns books say favor composition over inheritance:) Because the
> plan is to make all the extended validators capable of client side.
>
> As a reminder of the issue;
>
> http://www.irian.at/cagatay-validation-sandbox/home.jsf
>
> Regards,
>
> Cagatay
>

Mime
View raw message