2009年9月7日星期一

Re: [fw-mvc] Understanding 'Service Layer' and 'Domain Model'

Hi Colin,

The Service Layer is a very thin layer, a place where you find methods for easing the interaction with the Model with more aggregate means. For example, tasks which don't fit in just one domain object or mapper, or tasks which may use multiple model classes that can be aggregated into a single operation. There's no reason to use the Service Layer only - using the Model directly is perfectly fine.

The only soft rule that manages interaction is the simple warcry "Fat Model, Thin Controller!" ;). If you are doing a *lot* with models in a controller, and its a discrete repetitive operations, it might be something for the service layer to encapsulate for reuse and simplicity.

Paddy
 
Pádraic Brady

http://blog.astrumfutura.com
http://www.survivethedeepend.com
OpenID Europe Foundation Irish Representative



From: Colin J <colin.johnson@johnguest.co.uk>
To: fw-mvc@lists.zend.com
Sent: Monday, September 7, 2009 10:56:07 AM
Subject: Re: [fw-mvc] Understanding 'Service Layer' and 'Domain Model'


Keith

Thanks for your reply.  It is starting to make some sense now.  Would you
say that is it best practice that the Controller should always talk to the
service layer, or can it also talk to the Model (I mean model, not direct
sql queries!), for example, if it was a call to fetch a list of data from
the database?

Regards

Colin


keith Pope-4 wrote:
>
> 2009/9/1 Colin J <colin.johnson@johnguest.co.uk>:
>
>
> Technically services are part of the domain, they have a bit of a
> special place in the domain though, they provide services that do not
> naturally fit into the domain. (this is how I read the DDD book
> anyway)
>
> I have things like IO services as well as things that "extend" my core
> domain models like JSON services that transform the models output into
> JSON.
>
> Services are great for keeping things out of the main domain models.
>
> ACL in a service layer makes sense, much more than the in the
> application layer as you can then use it outside the MVC triad.
>
>
>

--
View this message in context: http://www.nabble.com/Understanding-%27Service-Layer%27-and-%27Domain-Model%27-tp25238912p25327932.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: