php - What, *specifically*, makes DataMapper more flexible than ActiveRecord? -


i'm comparing doctrine 2 , propel 1.5/1.6, , i'm looking in of patterns use. doctrine uses datamapper pattern, while propel uses activerecord pattern. while can see datamapper considerably more complicated, i'd assume design flexibility comes complication. far, legitimate reason i've found use datamapper on activerecord datamapper better in terms of single responsibility principle -- because database rows not actual objects being persisted, propel doesn't concern me because it's generated code anyway.

so -- makes datamapper more flexible?

i've worked both, new propel , doctrine2. datamapper (and mean doctrine2) makes adorable domain objects clean , simple, don't extend irrelevant classes add many irrelevant methods classes (violating srp said). they're simple entities few properties , few methods part of business layer. , that, of course, lets write unit tests them , reuse them in future.

i wouldn't datamapper considerably more complicated. complicated if write own implementation of datamapper, doctrine2 way easier use propel (maybe except setting up, once anyway). has entity manager manipulates entities. may have entity repositories complex queries. , that's it.

and entity simple as:

/**  * question  *  * @entity  */ class question {     /**      * @column(type="string")      */     private $title;      public function gettitle() { return $this->title; }     public function settitle($title) { $this->title = $title; }  } 

in propel have 6 classes entity contain lot of generated , unused code.

what makes datamapper more flexible? simplicity provides.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -