atdev — 2010-04-26T18:57:14-04:00 — #1
Where can I find some basic examples of these two design patterns?
Datamapper / Domain Object
I want to avoid ActiveRecord but am having a hard time differentiating it from Domain Object.
Some examples or skeleton/outlines of the classes would help.
lastcraft — 2010-04-27T05:09:36-04:00 — #2
I take it you've read the Martin Fowler book (Patterns of Enterprise Application Architecture)?
sunwukung — 2010-04-27T06:53:41-04:00 — #3
PHP Objects, Patterns and Practice:
Data Access Patterns: Database Interactions in Object-Oriented Applications
kyberfabrikken — 2010-04-27T07:39:33-04:00 — #4
Active Record is a way to create an object oriented domain model. Data mapper is another way.
sunwukung — 2010-04-27T07:48:20-04:00 — #5
in a nutshell
Active Record represents a one to one relationship between an object and a table on a database,
Data Mapper on the other hand can map several tables to one object (and back again).
romanb — 2010-04-27T11:56:37-04:00 — #6
I'm pretty sure you mean it that way but that should rather be:
"ActiveRecord is a way to persist an object oriented domain model. Data mapper is another way."
I think the difference is crucial
kyberfabrikken — 2010-04-28T09:08:16-04:00 — #7
Sort of. What I meant was that it's a particular way of implementing it. The problem with AR is that it couples persistence and domain model to each other.