php - Active Record must have domain logic? -
i started time working yii framework , saw things "do not let me sleep." here talk doubts how yii users use active record.
i saw many people add business rules of application directly in active record, same generated gii. believe misinterpretation of active record , violation of srp.
when talked people , view criticized. when asked:
and when need regenerate active record full of business rules through gii do? rewrite? copy , paste? that's great, congratulations!
got answer, silence.
so, i:
what doing in order reach little better architecture generate active records in folder /ar. , inside /models folder add domain model.
by way, domain model owns business rules, , domain model uses active records persist , retrieve data, , data model.
what think of approach? if i'm wrong somewhere, please tell me why before criticizing harshly.
some of comments on article quite helpful: http://blog.codeclimate.com/blog/2012/10/17/7-ways-to-decompose-fat-activerecord-models/
in particular, idea models should grow out of strictly 'fat model' setup need more seems quite wise.
are having issues or trying plan ahead? may hard plan ahead , may need refactoring go ...
edit:
regarding moveusertogroup
(in comment below), see how having might bother you. found thinking question: https://gist.github.com/justinko/2838490 equivalent setup might use moveusertogroup
cformmodel subclass. it'll give ability validations, etc, more specific you're trying handle (and use multiple ar objects achieve objectives instead of one).
i use cformmodel handle forms have multiple ar objects or forms want other things.
sounds may you're after. more details available here: http://www.yiiframework.com/doc/guide/1.1/en/form.overview
Comments
Post a Comment