我正在开发一个 API,供我们的供应商之一使用来访问我们数据库中的数据,并且我需要命名我的类。我正在考虑诸如 Retriever、Accessor 和 Controller 之类的名称(例如 TimesRetriever、TimesAccessor、TimesController 等)。这些类将提供对数据库中数据(我将进行总结)的只读访问。对于我所描述的内容是否有一个普遍认可的命名约定?
最佳答案
Martin Fowler (www.martinfowler.com) 是此类问题的良好来源;因为,你真正谈论的是设计模式。
我最好的猜测是存储库模式( http://martinfowler.com/eaaCatalog/repository.html )。
来自网站:
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.
听起来像是您正在尝试做的事情。
关于database - 从数据库获取数据的对象是否有通用名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1915060/