Assembling via Plain Code
Explore how to build a configuration component for assembling a web application starting from the main method. Understand the basic approach of manually instantiating and wiring components like web controllers and persistence adapters without frameworks. Learn the drawbacks of this plain code method and why dependency injection frameworks like Spring can better manage dependencies and visibility.
We'll cover the following...
Implementing the configuration component
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 what such a configuration component might look like. In Java, an application is started from the main method. Within this method, we instantiate all the classes we need, from web controller to persistence ...