This pattern belongs to Object-Relational Metadata Mapping Patterns Catalog and this Catalog belongs to Patterns of Enterprise Application Architecture . Intent Repository layer is added between the domain and data mapping layers to isolate domain objects from details of the database access code and to minimize scattering and duplication of query code. The Repository pattern is especially useful in systems where a number of domain classes are large or heavy querying is utilized. Real World Examples Spring Data Applicability Use the Repository pattern when the number of domain objects is large you want to avoid duplication of query code you want to keep the database querying code in a single place you have multiple data sources Explanation A system with a complex domain model often benefits from a layer, such as the one provided by Data Mapper , that isolates domain objects from details of the database access code. In such systems, it can be worthwh...
Creator is the GRAS Patterns (General Responsibility Assignment Software Pattern) Read about GRASP Patterns: GRASP Patterns Overview Problem Who should be responsible for creating a new instance of some class? The creation of objects is one of the most common activities in an object-oriented system. Consequently, it is useful to have a general principle for the assignment of creation responsibilities. Assigned well, the design can support low coupling, increased clarity, encapsulation, and reusability. Solution Assign class B the responsibility to create an instance of class A if one or more of the following is true: ? B aggregates A objects. ? B contains A objects. ? B records instances of A objects. ? B closely uses A objects. ? B has the initializing data that will be passed to A when it is created (thus B is an Expert with respect to creating A). B is a creator of A objects. If more than one option applies, prefer a class B which aggregates...
Comments
Post a Comment