Challenging development practices
We can say that Spring Framework development is straightforward and that there are few chances to make mistakes. That is mostly true. However, we will challenge some of the most commonly used Spring Framework features and discuss some of their drawbacks.
Reviewing dependency injection
As you already know, @Autowired
is the magic word that makes our lives easier. We inject the proper instance for the field and make it available in our code. Field injection is easy to do and very popular. The code we have is clear and easy to read and maintain. But there is something you should know about it!
Let's consider injecting our dependencies through the constructor. If we have one dependency, we will inject constructor that have for example one parameter. As the number of dependencies rises, the number of constructor parameters rises, too. Fortunately, this isn't a problem in Kotlin, where we have single-line constructors. At some point, you will realize that by injecting...