使用 DAO 读取 CSV 文件?
使用 DAO 模式访问 CSV 文件是可接受的做法吗?
我这么问是因为我通常有一个实用方法来读取 CSV。如果核心逻辑要与任何数据源完全分离,那么拥有 DAO 是有意义的。
Is it an acceptable practise to use a DAO pattern to access CSV files?
I'm asking because I'd usually have a utility method to read a CSV. Having a DAO would sort of make sense though if core logic is to be completely separated from any source of data.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DAO
是与存储库或背景故事交互的常见方式任何类型的。与其说它是一种设计模式,不如说它是一种将存储库与读取和存储功能进行交互的方法。如果您针对接口进行编程,您可以轻松实现按照您的建议连接 CSV 文件的文件系统。但是,如果您只是打算制作一个 CSV 阅读器,那么提供 CSV 解析器或某种
编组
或序列化 抽象。
DAO
is a common way to interface with a repository, or backing story of any kind. It's not such much of a design pattern as a means to interface a repository typically with read and store functionality.If you program against an interface you can easily make an implementation which interfaces a filesystem of CSV files as you proposed. However if you're just going to make a CSV reader it would probably make more sence to provide a
CSV Parser
or some kind ofmarshalling
orserialization
abstraction.