On Nov 23, 2007 8:09 AM, Alan Livie <[EMAIL PROTECTED]> wrote:

>
> I am working on validation for my User cfc. On different parts of the
> site when users register different criteria are asked for.
>
> ie we offer a quick registration process where only email, username
> and password are mandatory. There is also a full registration where
> additional fields are mandatory. There will also be a third situation
> where different fields are mandatory if they are on the American
> version of the site, also slight changes for the German site.
>
> I thought that rather than have all the conditional code inside the
> bean that will constantly need tweaked I would use either State or
> Strategy pattern.
>
> State makes more sense to me and would create an abstract class (cf7
> at the mo so no interfaces) called UserValidationState which would be
> subclassed by QuickRegValidation.cfc, FullRegisterValidation.cfc,
> QuickRegValidationUS.cfc etc etc and compose these concrete CFC's
> using the State pattern.
>
> I have a little bean factory that will create and compose the cfc's
> when a User object is created. Either client code or a service cfc
> will determine the state the object will be in when it is created.
>
> I'm interested in how others would approach it.
>
> Is using State the best way to do this or does Strategy make more
> sense (or something else I haven't thought of)?
>
> Lots of if statements in User.cfc is the one thing I don't want!
>
>
Alan,

Going over each pattern as a refresher, it looks as if they are the same
with slightly different contexts and intents.

I guess choosing between the two is only a contest for whose name gets to be
used, then.

How would your code or idea you mentioned above change if you decided to go
with Strategy?

Anyway, for me, I think it makes more sense to speak of
UserValidationStrategies than UserValidationStates, but really, I'm not sure
it makes a difference in the code, only how we communicate about it.  And,
as long as no one is going to get religious about it one way or another,
just making a decision on what to call it and sticking to it is probably
just as good.

Sam

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CFCDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cfcdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to