Skip to content

Consider using the DAO pattern?  #10

@jasperblues

Description

@jasperblues

This looks super cool, but have you considered using the DAO pattern as an alternative to the ActiveRecord style approach?

A Data Access Object (DAO) is an interface dedicated to the persistence of a model/domain object to a data-source.

The ActiveRecord pattern puts the persistence methods on the model object itself, whereas the DAO defines a discrete interface.

The advantage of using data access objects is the relatively simple and rigorous separation between two important parts of an application that can and should know almost nothing of each other, and which can be expected to evolve frequently and independently. Changing business logic can rely on the same DAO interface, while changes to persistence logic do not affect DAO clients as long as the interface remains correctly implemented.

  • Its easy to define another style of persistence, eg moving from a Database to cloud, without changing the interface and thus effecting other classes.
  • The persistence concerns are modularized away from the main model object concerns.
  • Non-invasive - ie you don't have to extend a special base class.

The advantage of the ActiveRecord pattern is simplicity.

You could even use the DAO pattern behind the scenes, so that the ActiveRecord style methods map to a default (NSCoding), but change-able implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions