2008年7月23日星期三

Re: [fw-mvc] 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

没有评论: