Skip to content
This repository was archived by the owner on Sep 3, 2021. It is now read-only.
This repository was archived by the owner on Sep 3, 2021. It is now read-only.

Implement Data Mapper pattern instead of Active Record #62

Description

@bwhitty

Opening this issue to discuss how the Model layer is going to be implemented.

I propose we implement the Data Mapper [1] pattern instead of the currently planned Active Record pattern. I say this because that while the Active Record pattern may be easy at first and faster to implement, it violates the single responsibility principle in that it concerns itself with both domain logic and persistence [2]. Also as Titon is a framework, it needs to be as flexible as possible so decoupling is key.

To go along with the Data Mapper pattern, there is also usually a service layer. All this service layer does is marry domain objects to their data mappers and are the end-user interface. You would then use a service in, say, the controller layer [3].

This whole pattern adds extra complexity through layers of abstraction, but it is much more extensible and testable. Thoughts?

1: http://martinfowler.com/eaaCatalog/dataMapper.html
2: http://russellscottwalker.blogspot.com/2013/10/active-record-vs-data-mapper.html
3: http://www.slideshare.net/aaronsaray/enterprise-php-mappers-models-and-services

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions