Rob, how do you feel about this somewhat different statement I gave on a
fw-db thread:

Q: "Is there a best practice when it comes to defining models on top of
the Zend_Db_Table_Row class?"

Regarding best practices of defining models, this is a frequently asked
question.  It's hard to make a one-size-fits-all solution for this,
because application requirements vary so much.  In some cases, you can
define a model class that extends Zend_Db_Table_Abstract or
Zend_Db_Table_Row_Abstract.  But it's my belief that most apps have
requirements for business logic that make this an ill fit.  You'll soon
find cases where you need to write a model class that extends nothing
(i.e. your model is itself a base class) and it may _use_ one or more
Table or Row objects, in addition to other resources.  
 
Both simple and complex cases exist, so don't feel constrained to define
models in a particular way in every case.  Step back and do the analysis
necessary to find the best OOP solution.  Also keep in mind that there's
no requirement for a given controller action to use only one model
object.  It's okay for a controller to create instances of multiple
models.  So let the OO analysis determine which code belongs in which
class.

Regards,
Bill Karwin 

> -----Original Message-----
> From: Rob Allen [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, July 22, 2007 6:02 AM
> To: ZF General
> Subject: Re: [fw-general] Data models
> 
> Karol Grecki wrote:
> > Hi Rob,
> > 
> > Applications tend to evolve, often beyond what you expected. 
> 
> Of course.
> 
> > Creating a proper model that is decoupled from a database 
> is not that 
> > much effort.
> > And it may benefit you greatly if you're building non trivial 
> > application
> > 
> 
> Strikes me as a case of YAGNI. If at some point in the future 
> you need your press-releases model to start supporting SOAP, 
> then that's the time to refactor.
> 
> I was mainly commenting on the blanket comment by Bill that 
> using Active Record (i.e. Zend_Db_Table / Zend_Db_Table_Row 
> with business logic in
> it) is a bad idea.
> 
> Regards,
> 
> Rob...
> 

Reply via email to