tags:

views:

580

answers:

1

What are the advantages and disadvantages of both active record and data mapper?

Please be PHP-specific, where the language matters.

Personal experiences are welcome! Ideally with both.

+4  A: 

Active record:
advantages:
-simplicity
disadvantages:
-responsibility of storage should be a seperate responsability
-static methods are more difficult to test
-persistence often globally accessed
-active record often mistaken to be the domain object itself (example: cakephp)

Data mapper:
advantages:
-clear responsability: storing/retrieving domain objects, no mixing of concerns here
-as a result more easy to inject persistence collaborators
disadvantages:
-can be overkill on small projects that will not grow

disclaimer: I'm strongly biased in favor of the data mapper

koen
+1 but I'm still waiting for more answers or additions. Personal experience is welcome and wanted!
Flavius