What type is repository pattern in?

与世无争的帅哥 提交于 2019-11-30 09:01:04

Repository can be viewed as a special kind of Façade (structural) but also as a special kind of Factory (creational). Also, as the Repository often expose collection-like interface, then it might be a special application of Iterator (behavioral).

What I am trying to say is that neither those categories nor patterns themselves are any sort of definite doctrine. There are just some ideas and a language that tries to make them more explicitly visible. These categories are just helpers trying to express somehow what some patterns do. Also patterns are just various expressions of a generic loose coupling principles. Their borders are blurry.

A repository is a specialisation of the Facade pattern which is structural.

I assume you refer to the repository pattern by Martin Fowler.

He says:

Repository: Mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects.

He himself categorizes the pattern as "Object-Relational Metadata Mapping".

If you want to use the categories in the GOF book, I'd put it into the structural pattern category as the focus of this pattern is to present an interface/view to a client, similar to the Adapter/Facade/Proxy patterns.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!