Well, some DBs will let you have nested transactions, AFAIK, so that might
be an option (in other words, just put the transaction logic in both
saveUser and saveUsers.

Also, if saveUsers (or, saveUserBatch, in your lexicon) is just going to
call the same few methods of your persister, I would say it might be OK if
the code of saveUser and saveUserBatch look similar -- you avoid most of the
drawbacks of redundancy by using the API of your persister, and you just
accept a certain amount of redundancy in order to accommodate your needs.
The nice part is that by using the "UserManager" as what the developer uses,
the person actually writing code against it doesn't need to care about how
you implement it internally, so you can get it working and worry in the next
round of revision about optimizing the code underneath.





> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Jay Gibb
> Sent: Tuesday, November 18, 2003 2:23 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [CFCDev] cftransactions in low level modules
>
>
> Thanks Nathan.. I don't think you're missing the boat at all.  This is
> exactly like the problem I'm attempting to solve.
>
> To recap..
>
> These functions do not contain any transaction logic at all...
>
> insertUser(id,fname,lname,email);
> associateUserWithDepartment(userID,deptID);
> associateUserAsDirectReport(userID,bossID);
>
> This function exists within the UserManager and contains the transaction
> logic...
>
> saveUser(user,deptID,directReportID);
>
> That handles this transaction: "insert a user and associate him/her with a
> given department and make them a direct a report of another given user"
>
> ...but...
>
> What about this transaction: "insert a batch of users"?
>
> Ideally, I'd like to loop through a batch of saveUser() function
> calls (and
> roll them all back if any error is thrown).
>
> Perhaps I'm "over-modularizing" here.  I could clearly have a
> saveUserBatch
> that calls insert/associate/associate for each user in the batch, but that
> seems like code duplication I could easily avoid if there were a way to
> "turn-off" the transaction logic in saveUser().
>
>  - j.

----------------------------------------------------------
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