tag:blogger.com,1999:blog-6163975526168599737.post612045450023194490..comments2022-12-03T09:44:07.839+00:00Comments on Mooduino: Fat Models and Thin Controllers with the Zend FrameworkAnonymoushttp://www.blogger.com/profile/10540099897873200193noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-6163975526168599737.post-17736730925872763672010-10-26T23:52:17.042+01:002010-10-26T23:52:17.042+01:00Once and for all, a model SHOULD NOT be derived fr...Once and for all, a model SHOULD NOT be derived from Zend_Db_Table_Row_Abstract.<br /><br />The relationship between an application model and Zend_Db_Table_Row_Abstract should not be a IS-A, it should be a HAS-A!Shadowedhttps://www.blogger.com/profile/18204200546622309579noreply@blogger.comtag:blogger.com,1999:blog-6163975526168599737.post-73940339407964618882010-09-26T15:09:39.382+01:002010-09-26T15:09:39.382+01:00You need a Service Layer !You need a Service Layer !Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6163975526168599737.post-59065088217867061852010-09-24T18:43:20.006+01:002010-09-24T18:43:20.006+01:00Hey Moo,
I agree with Michelangelo. Zend_Form ca...Hey Moo,<br /><br />I agree with Michelangelo. Zend_Form can be used as an input filter and validator without ever using it for user interface. The only time decorators are applied and html is output is when you call render on the form.<br /><br />As to your concern about coupling, I agree, you want to be able to test your model and only the model. However, in the implementation you have above, you have hard dependencies on Zend_Validate classes.<br /><br />If you pass your Zend_Form object into your model's constructor, you can mock the form out when you're unit testing, you no longer have tight coupling between the form and your model, and you can clean out the Zend_Validate and Zend_Filter classes that you have hanging out in your models and controllers. <br /><br />You'll also be able to cut your models code by at least 2/3, providing higher cohesion in your models.<br /><br />My $0.03.Jeremy Kendallhttp://jeremykendall.netnoreply@blogger.comtag:blogger.com,1999:blog-6163975526168599737.post-858547833474305522010-09-24T09:04:40.717+01:002010-09-24T09:04:40.717+01:00Hi Michelangelo
Thanks for the comment. You know,...Hi Michelangelo<br /><br />Thanks for the comment. You know, if that works for you, then great, I can totally see that working. For me though, I'm not sure I like the idea of tightly coupling my models to Zend_Form as it presupposes that Zend_Form is the only user interface into the model. When I Unit test my models, I want to be testing the model, not the form.Anonymoushttps://www.blogger.com/profile/10540099897873200193noreply@blogger.comtag:blogger.com,1999:blog-6163975526168599737.post-7476386772331685392010-09-24T07:50:25.298+01:002010-09-24T07:50:25.298+01:00I like the way you describe the fat models, but I&...I like the way you describe the fat models, but I'm kinda confused here.<br /><br />Since you both have a model and a form, it would be more logic to create a separate form class extending Zend_Form that you can set in your model for filtering and validation purposes. This way you have best of both worlds (model containing and modifying data and your form object for filtering and validation) without mixing each purpose. And it can be reused in more than one way.<br /><br />Just my $ 0.02,<br /><br />MichelangeloM. van Damhttps://www.blogger.com/profile/12610668749799675317noreply@blogger.com