Further to my last post: would it be even better to take a totally
different approach and pass all form/event data through to the service
layer as a Struct so that it has all the population logic?
*** Listener code (version 5) ***
var sData = StructNew();
sData['userId] = event.getArg('user_id');
sData['firstName] = event.getArg('first_name');
sData['galleryId] = event.getArg('gallery_id');
getUserService().saveUser(sData);
Cheers
Matthew
On Sep 16, 9:53 am, Matthew <[email protected]> wrote:
> @Matthew, @ jlcox: Thanks for the reply guys. Makes sense. So how
> would you script this? Would you have a 'getGallery' method on the
> User service or would you pass the 'saveUser' method the 'gallery_id'
> attribute and it does the rest:
> *** Listener code (version 3) ***
> var oUser = getUserService().getUser(event.getArg('user_id'));
> var oPhotoGallery = getUserService().getGallery(event.getArg
> ('gallery_id')); // *** THIS WOULD CALL THE PHOTO GALLERY SERVICE FROM
> THE USER SERVICE***
> oUser.setFirstName(event.getArg('first_name'));
> oUser.setGallery(oPhotoGallery);
> getUserService().saveUser(oUser);
> *** Listener code (version 4) ***
> var oUser = getUserService().getUser(event.getArg('user_id'));
> oUser.setFirstName(event.getArg('first_name'));
> oUser.setGallery(oPhotoGallery);
> getUserService().saveUser(oUser,event.getArg('gallery_id')); // ***
> HERE I AM PASSING IN THE GALLERY ID FOR THE SAVEUSER METHOD TO GET AND
> ASSIGN THE PHOTO GALLERY OBJECT ***
>
> I don't really like either solution because the 1st option requires a
> duplicate getGallery method and the 2nd option doesn't scale very well
> i.e. as you get more dependencies you have to pass the 'saveUser'
> method more and more id's of the dependent objects.
>
> Cheers
> Matthew
>
> On Sep 16, 12:08 am, Matthew Woodward <[email protected]> wrote:
>
> > jlcox wrote:
> > > I'd call the PhotoGallery service from the UserService (or v/v).
>
> > I'd do the same. The question I always ask myself is if what I'm dealing
> > with in my listener is more business logic or application flow logic.
> > Having to persist one-to-many or many-to-many relationships is
> > definitely part of the business logic in my mind, so that belongs in the
> > service, not in the listener.
>
> > --
> > Matthew Woodward
> > [email protected]http://mpwoodward.posterous.com
> > identi.ca/Twitter: @mpwoodward
>
> > Please do not send me proprietary file formats such as Word, PowerPoint,
> > etc. as attachments.http://www.gnu.org/philosophy/no-word-attachments.html
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to Mach-II for CFML list.
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/mach-ii-for-coldfusion?hl=en
SVN: http://greatbiztoolsllc.svn.cvsdude.com/mach-ii/
Wiki / Documentation / Tickets:
http://greatbiztoolsllc.trac.cvsdude.com/mach-ii/
-~----------~----~----~----~------~----~------~--~---