I'm a Java developer working on a new module for my app that connects to, inserts, and updates DynamoDB information. For a lot of our projects, I used an MVC design pattern with a service layer to abstract business logic and bridge the gap between my controllers and model/data access layer.

We normally use PostgreSQL with an ORM to interact with data.

I have all of my credentials and dependencies to connect to my DynamoDB database. I'm just not sure what the best practice is in terms of where to put this. I read AWS SDK suggests using the builder methods to connect, which I have, but I'm not familiar with the builder design pattern (that may not even be relevant).

My first inclination is to call this new DynamoDB connection class DynamoDBClient, but upon doing some searching I don't see anything about adding a client layer to a software tier. I could make a new package (com.carella.anthony.clients), but is that common practice?

Where should I put this? Or rather, how should I construct this into my application?

1 Answer 1


I would suggest adding a new package Infrastructure that contains all the configurations and connections for all your database/caching/messaging systems.


The credentials should be managed by a DynamoConfiguration class that reads from a configuration file.

The connection itself should be managed by a DynamoConnection class that accepts a DynamoConfiguration as a parameter and builds the connection during the object initialization.

public class DynamoConnection implements IDynamoConnection {

    private final AmazonDynamoDB connection;
    private final DynamoConfiguration config;

    public DynamoConnection(DynamoConfiguration config) {
        this.config = config;
        this.connection = AmazonDynamoDBClientBuilder.standard()

    public AmazonDynamoDB connection() {
        return this.connection;

It would look something like the code above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.