Assembling via plain code
There are several ways to implement a configuration component responsible for assembling the application. If we’re building an application without the support of a dependency injection framework, we can create such a component with plain code:
This code snippet is a simplified example of how such a configuration component might look. In Java, an application is started from the main method. Within this method, we instantiate all the classes we need, from the web controller to the persistence adapter, and wire them together.
Finally, we call the mystic method startProcessingWebRequests(), which exposes the web controller via HTTP.1 The application is then ready to process requests.
1 The method startProcessingWebRequests()is just a placeholder for any bootstrapping logic that is necessary to expose our web adapters via HTTP. We don’t really want to implement this ourselves. In a real-world application, a framework...