开发者

DAL: Is it ok to incapsulate several data sources access in one module?

开发者 https://www.devze.com 2023-01-15 08:28 出处:网络
Application I develop requires several data sources (2 RDBMS and one file stora开发者_如何学JAVAge) to operate. I\'m going to incapsulate datasources with DAL library & Business Logic layer.

Application I develop requires several data sources (2 RDBMS and one file stora开发者_如何学JAVAge) to operate. I'm going to incapsulate datasources with DAL library & Business Logic layer.

Would you personally create several DAL libraries (each per data source) and cooperate several DAL instances in Business Logic Layer or create monolith DAL library, that incapsulates all datasources application uses?


It's difficult to tell without more information but if there are going to be a lot of methods for each data source I'd be inclined to create separate DALs.

It is then possible other applications (only interested in one of the data sources) could re-use one of the DALs - they won't have to deal with unrelated methods/data sources.

More importantly, make sure you inject your DAL into the business logic layer so you can test the business logic layer without actually using the "real" data source.

0

精彩评论

暂无评论...
验证码 换一张
取 消