0

This question is to understand the pros & cons for keeping the DAO's with the service or as a separate package being consumed by the services.

Consider a micro-service architecture. Let's say I have 5 different services which constitute a System. Then there is a Database (MySQL or Amazon DynamoDB) which these services communicate with.

There appear to be 2 ways to design the Data Access Layer

  1. Design a separate package which encapsulates all the DAO's for the tables.
    Each service can add a dependency on this DAL and talk to the database. This would result in any changes being restricted to this package only. But would result in re-deployment in each micro service since all of them consume this DAL.
  2. Integrate the DAO's within each service itelf.
    This would lead to only the relevant service being changed in case any database layer changes occurs (except thing like re-architecturing, or other system wide changes).

Both approaches seem fine to me. Could you guys share some inputs on them - which one to pick under which scenario, pros and cons of the 2 appproaches?

7
  • For scenario #1. Did you think to make DAL as shared library? Shared libraries are deployed into the app server and foreing apps only need to refer to them as a server resources. In Java there're app servers that allows to do it easly. What's your platform? Commented Apr 17, 2016 at 9:15
  • My company has its own custom frameworks. Typically I have seen teams create a separate library package for DAL which encapsulates the Database Architecture from the application layer. The DAL is then added as a direct dependency of the Services. Commented Apr 17, 2016 at 16:46
  • Yes. It's a good practice. But looks like a bad choice in your enterprise-architecture. However to make such lib a sharedlib would fit perfectly and no re-build, re-deploy would be needed of every service. Unless changes on services were demand it. Commented Apr 17, 2016 at 17:04
  • @Laiv could you refer me to some documentation on creating shared libs in Java. Commented Apr 18, 2016 at 9:48
  • Every Application Server has its own mechanisms. What's your container (JBoss, Weblogic, Tomcat? Sharedlibs can be packaged like jars, ears, wars and every App server deploy'em in different ways. Commented Apr 18, 2016 at 10:44

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.