I usually do something like this: the MG controller talks to a ContactService.
The ContactService
in turn decides on what it needs to do and either talks to a DAO to get a single record (getting a
bean or a struct or whatever in return) or a ContactGateway object, which in turn does aggregate access.
E.g.
ContactService:
-getContactByID() returns ContactBean or something
-getLatestContacts(int days, int howmany) - which internally defers to a ContactGateway object which
pretty much just calls a method of the same name and passing in the same parameters (or different)
ones, whatever you need).
So really your controller only talks to the Service which makes defers handling to child objects, or
maybe to other services, or to other DAOs, or to other gateways, etc. as needed.
/Cody
Cody Caughlan wrote:
I agree. I wasnt really thinking straight when I wrote that. I agree,
the top 5 query should be in the ContactGateway.
/Cody
Jeff D. Chastain wrote:
Well, my thought was that the "top 5" query would actually be in the
contact gateway object. The question then arises though as to whether
the MG controller is talking directly with the gateway object or if it
should be talking to the service layer? If it is talking to the
service layer, then how do you break up different functions into
different services?
Thanks.
------------------------------------------------------------------------
For aggregate access, e.g. Get me the Top 5 most recently updated
contacts, this should be a query.
You could write code to instantiate 5 Contact objects, each with their
own Phone, Address, etc.
objects but that is way overkill and anti-performant. Your Service
layer would contain this one
method that returns the query representing these 5 contacts.
/cody
Jeff D. Chastain wrote:
> I am working on a simple contact manager type application using MG
Unity
> and some other things I wanted to play with. I have built all of my
low
> level data objects (bean, dao, gateway) for a Contact, which has
one or
> more Addresses, which then has a State and a Country.
>
> Where I am getting stuck is on the "service" layer. In once case, I am
> looking to create functionality where an entire contact could be
updated
> at once by passing in a struct (i.e. the form scope). So in my mind
> this means a ContactService with a method to update the contact and
that
> method then utilizes the different contact, address, state, and
country
> beans and daos.
>
> Another requirement though is to obtain a list of the 5 most recently
> updated contacts. Is this something that would go in the same
> ContactService or where would this go? I have never had a good
grasp on
> what should go where in terms of a service layer, so I am looking for
> any input on how service layers are really built and organized.
>
> Thanks
> -- Jeff
>
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of
the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.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 words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]