Where to instanciate adapters in hexagonal architecture

I am building a simple application with the trying to follow best practices with hexagonal architecture. My main entry point is my manual dependency injection starter, I usually considered this code as the application part but I have to instanciate adapters creating a hard coupling between adapters and the application part breaking the dependency rule. So where should I instanciate the adapters manually?

Upvotes: 1

Views: 414

Answers (1)

Julien Gavard
Julien Gavard

Reputation: 683

It's effectively a layer coupling problem.

I think, you can put your starter in the Adapter's layer in your hexagone because your hex should be free of knowledge of Adapters implementation.

You can also put your starter at the root of your source code or in a low level configuration part of the app.

In addition, think of automatic injection (like CDI in Java).

Upvotes: 1

Related Questions