logo       

Re: Best practices in a thin-controller application: msg#00136

php.zend.framework.mvc

Subject: Re: Best practices in a thin-controller application

Hi Adam,

Adam Jensen wrote:
See why it's helpful to be able to construct the Travel_Trip object
from the row? It saves Travel_Trip from having to reload an
already-loaded row from the database. It does so, however, at the
expense of Travel_Agent being aware of the fact that Travel_Trip is
backed by a database table.

Comments? Is there a way to keep from having to reload the row
without exposing Travel_Trip's database dependency?


The more you want your domain objects to be ignorant of the database storage, the more you're going to need a separating layer, such as a Data Mapper [1], to isolate the dependencies. It's a classic trade-off: the simplicity of directly modeling the table structure conflicts with the flexibility and expressiveness of "pure" objects. You just have to pick a comfortable point on that continuum for your application. :)

[1] http://martinfowler.com/eaaCatalog/dataMapper.html

Regards,
Bryce Lohr




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise