I usually have a reference to my Manager in my business objects.  So my
Question objects would be passed a reference to my SurveyManager object when
constructed.  Then they can call methods of the manager as needed.  So
inside Question.updateInfo(), there would be a line like this:

isNameUnique = getSurveyManager().isQuestionNameTakenOnPage(getPage(),
arguments.name);

So the surveymanager will need a method (isQuestionNameTakenOnPage) that
takes a page object and a question name, and returns whether or not that
name is already taken on the page.  You'll have to handle the case where
you're updating a page without changing the name (it'll return true, because
the current question is already on the page), but that's simple enough.

I'm not sure of the specifics of your model, so this will undoubtedly need
some tweaking, but hopefully will be of assistance.

cheers,
barneyb

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Jon Gunnip
> Sent: Tuesday, October 14, 2003 1:20 PM
> To: [EMAIL PROTECTED]
> Subject: [CFCDev] Deciding where to Implement Business Rules
>
>
>
> Hello,
>
> I'm struggling to determine where  to represent some business
> rules in my CFC's.  I apologize in advance for the length of my email.
>
> I am building a Survey system, and I am currently designing the
> components.  (I'm planning on implementing this system in Mach-II.)
>
> There is a nice hierarchical relationship in the system: each
> user will have zero or more surveys, each survey will have one or
> more pages, and each page will have one or more questions.
>
> I currently have the following components: SurveyManager.cfc
> (manages a user's surveys), Survey.cfc (represents a survey,
> contains Page objects), Page.cfc (represents a page, contains
> Question objects), and Question.cfc (represents a question).
>
> There are some naming dependencies between the objects: survey
> names should be unique for a given user, survey page names should
> be unique within a given survey, and survey questions should be
> unique within a given survey.
>
> My concern is: Where do I enforce the uniqueness of names for
> these objects?
>
> Take the example of a user updating the name to an existing
> Question on a particular Page in a particular Survey.
>
> It seems like I have 3 options:
>
> 1) Have Question.UpdateInfo() examine other Question objects in
> the survey to ensure the new question name is unique (But I feel
> this should be some other object's concern - a Question should
> not have to know about the Page or Survey it is in)
>
> 2) Have the SurveyManager be the interface for all Survey, Page,
> and Question updates and let it do the checking (but this seems
> like a lot of duplication of add/delete/update functions because
> there would have to be a SurveyManger wrapper function for each
> public function of Survey, Page, and Question e.g.
> SurveyManager.UpdateQuestionInfo() would be a wrapper for
> Question.UpdateInfo() )
>
> 3) Have a page that processes an update to a question validate
> that a question name is unique in a survey before calling
> Question.UpdateInfo() directly  (but then it seems like I am not
> enforcing my business rules in my model, and I might have to
> re-write the business rules for uniqueness of question names if I
> used a different user interface)
>
> Any suggestions?
>
> Thanks,
> Jon Gunnip
>
>
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> in the message of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
>
> An archive of the CFCDev list is available at
> www.mail-archive.com/[EMAIL PROTECTED]
>

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to