I would like to see how good models look like in real app, Action
Controller --> Service Layer(s) --> Model(s) --> Table(s). flow in real
example.
I use to simplify my app by extending Zend_Db_Table and using it as a model,
used Zend_Db_Table_Row as a model too, but looks like that is not a good
idea, maybe they should be used like POJOs in hibernate apps not like Table
Data Gateway. Also, domain model is not always the best solution. Data
mapper is good, but I'm always comfused on how mapper should really look
like.
Is there a real good example out there, maybe some github url?
Regards,
Saša Stamenković
On Sun, Nov 7, 2010 at 5:35 PM, Bill Karwin <bill@karwin.com> wrote:
> I agree that it's not a good idea to treat the Action Controller as a
> Service Layer. I was allowing for the fact that some developers simplify
> their apps by combining these classes. But that can result in confused
> terminology. Zend_Db_Table is not a Model class, and the Action Controller
> is not a Service Layer.
>
> The calling order of classes should be as follows:
>
> Action Controller --> Service Layer(s) --> Model(s) --> Table(s).
>
> The Service Layer is the best place to start and commit/rollback
> transactions.
>
> Also see http://www.martinfowler.com/eaaCatalog/serviceLayer.html
>
> Regards,
> Bill Karwin
>
>
> On Nov 7, 2010, at 1:32 AM, umpirsky wrote:
>
>
>> I already done that.
>>
>> But i don't think controller should be the place where db transactions are
>> handled. Maybe there should be 2 layers in modeling, Db_Table_* classes,
>> and
>> on top of them layer of models above, where transactions can be tracked.
>> But
>> again, there can be controllers which combines multiple models methods and
>> there we are in trap again. Making plugin to start transaction on
>> preDisplatch and commits on postDispatch is not good idea :)
>>
>> Regards,
>> Saša Stamenković
>>
>>
>> On Sat, Nov 6, 2010 at 9:39 PM, Wil Moore III [via Zend Framework
>> Community]
>> <ml-node+3030338-125745325-105879@n4.nabble.com<ml-node%2B3030338-125745325-105879@n4.nabble.com>
>> <ml-node%2B3030338-125745325-105879@n4.nabble.com<ml-node%252B3030338-125745325-105879@n4.nabble.com>
>> >
>>
>>> wrote:
>>>
>>
>> As suggested by Bill, a service layer is what you want; however, for
>>> testability, I would recommend that you factor this out of the controller
>>> and into a service object. Of course, you can start with the
>>> functionality
>>> in the controller then slowly move toward a service object.
>>> --
>>> Wil Moore III
>>>
>>> Why is Bottom-posting better than Top-posting:
>>> http://www.caliburn.nl/topposting.html
>>>
>>>
>>> ------------------------------
>>> View message @
>>>
>>> http://zend-framework-community.634137.n4.nabble.com/Nasted-transactions-tp3028213p3030338.html
>>> To unsubscribe from Nasted transactions, click here<
>>> http://zend-framework-community.634137.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_code&node=3028213&code=dW1waXJza3lAZ21haWwuY29tfDMwMjgyMTN8MTU2NDkwODkwNw==
>>> >.
>>>
>>>
>>>
>>>
>> --
>> View this message in context:
>> http://zend-framework-community.634137.n4.nabble.com/Nasted-transactions-tp3028213p3030660.html
>>
>> Sent from the Zend DB mailing list archive at Nabble.com.
>>
>
>
没有评论:
发表评论