Skip to content

Sample implementation of Repository Pattern defined in Patterns of Enterprise Application Architecture.

Notifications You must be signed in to change notification settings

tatsuya/repository-pattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

repository-pattern

Sample implementation of Repository Pattern defined in Patterns of Enterprise Application Architecture.

Basic ideas are:

  • A Repository mediates between the domain and data mapping layers
  • Mapping code is encapsulated behind the Repository
  • Clean separation and on-way dependency between the domain and data mapping layers

Implementation Details

Entity

In this sample the following two types of entities are used.

  • Company - Represents the company contains company name and URL of company website.
  • Contact - Represents the contact information of employee includes first name and last name.

Both of entities inherit from abstract class called Entity. The Entity class only has one id field which represents the unique identifier of each entity.

Repository

The repository represents the collection of entities.

  • CompanyRepository - Collection of company entity.
  • ContactRepository - Collection of contact entity.

Repository Strategy

There are three types of repository strategies are implemented.

  • InMemoryStrategy - Queries the in-memory collection objects
  • FileStrategy - Queries the files in local filesystem
  • MongoStrategy - Queries the MongoDB

Each strategy implements the RepositoryStrategy interface, which exposes general CRUD methods.

About

Sample implementation of Repository Pattern defined in Patterns of Enterprise Application Architecture.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages