I´m pretty sure it´s not the gang of four. I have a feeling this is a newer pattern. Where was it first published/mentioned?
-
4I would note that the authors of these books are very rarely the creator of the patterns. The gang of four explicitly say they didn't create them, they were just documenting commonly used patterns.– Tom SquiresFeb 1, 2012 at 12:02
-
3"Design patterns" are never invented by anyone in particular. Design patterns are common elements of designs that repeatedly shows up in various successful designs. In most cases, it only makes sense to talk about who coined the terms or who first wrote about the pattern.– Lie RyanAug 25, 2013 at 0:40
2 Answers
The earliest mention of it that I can find is in this paper, "An Introduction to Software Architecture", by David Garlan and Mary Shaw (1994, first published 1993). That predates the Gang of Four by a year, so it's an older pattern rather than a newer one.
Martin Fowler and Eric Evans have both mentioned it in their books and popularised it, but it's been around for a while.
-
Actually the GoF book was also published in the same year (says my memory... and Wikipedia too). And note that all of these patterns had been around for quite a while before getting published, so one can't really claim this pattern is older than that one, only that it was published earlier. Feb 1, 2012 at 12:23
-
1The paper was first published in 1993 though. Edited my answer to clarify!– LunivoreFeb 1, 2012 at 13:36
-
1@Lunivore I had a look at the Garlan/Shaw publication PDF you linked to. I didn't see "Repository Pattern". That might be referring to "Repository = a place to store data", rather than "Repository Pattern = a collection API". I only read it briefly though. Please clarify how you saw the connection. Thanks. Oct 19, 2021 at 11:58
-
@KindContributor An API is just the interface to an application, service or module, i.e.: the way in which you use it, where "you" is another system as opposed to a GUI which is for human users. So if you have a collection of things which are stored somewhere, then you will access it through a collection API. Please bear in mind also that this was answered in 2012, before the advent of cloud etc. - the usage may have changed over time.– LunivoreOct 21, 2021 at 11:55
-
@KindContributor (Also worth noting that pattern language is just a particular encoding of expertise and common practices - even if it isn't phrased in pattern language, it can still be a pattern.)– LunivoreOct 25, 2021 at 12:13
I saw it first published in Martin Fowler's Patterns of Enterprise Application Architecture (2002).
Mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects.
For a full description see P of EAA page 322
A system with a complex domain model often benefits from a layer, such as the one provided by Data Mapper (165), that isolates domain objects from details of the database access code. In such systems it can be worthwhile to build another layer of abstraction over the mapping layer where query construction code is concentrated. This becomes more important when there are a large number of domain classes or heavy querying. In these cases particularly, adding this layer helps minimize duplicate query logic.
A Repository mediates between the domain and data mapping layers, acting like an in-memory domain object collection. Client objects construct query specifications declaratively and submit them to Repository for satisfaction. Objects can be added to and removed from the Repository, as they can from a simple collection of objects, and the mapping code encapsulated by the Repository will carry out the appropriate operations behind the scenes. Conceptually, a Repository encapsulates the set of objects persisted in a data store and the operations performed over them, providing a more object-oriented view of the persistence layer. Repository also supports the objective of achieving a clean separation and one-way dependency between the domain and data mapping layers...