sdeleuze
09/26/2017, 12:30 PMCzar
09/26/2017, 12:47 PMqwert_ukg
09/27/2017, 11:06 AMqwert_ukg
09/27/2017, 11:06 AMqwert_ukg
09/27/2017, 11:07 AMenleur
09/27/2017, 11:10 AMenleur
09/27/2017, 11:11 AM@Component
class MyBean(val a: SomeBean)
nfrankel
09/27/2017, 11:27 AMqwert_ukg
09/27/2017, 11:35 AMqwert_ukg
09/27/2017, 11:36 AMlateinit
enleur
09/27/2017, 11:37 AMqwert_ukg
09/27/2017, 11:38 AMqwert_ukg
09/27/2017, 11:39 AMenleur
09/27/2017, 11:39 AMThe reasons why field injection is frowned upon are following:
You cannot create immutable objects as with constructor injection
Your classes have tight coupling with DI container and cannot be used outside of it
Your classes cannot be instantiated (for example in unit tests) without reflection. You need the DI container to instantiate them, which is more like integration tests
Your real dependencies are hidden from outside and are not reflected in your interface - constructors or methods
It is really easy to have like 10 dependencies. If you were using constructor injection, having constructor with 10 arguments will signal that something is fishy. But you can add injected fields using field injection indefinitely. Having too many dependencies is a red flag that the class usually does more than one thing and it may be a violation of a Single Responsibility Principle.
qwert_ukg
09/27/2017, 11:39 AMhho
09/27/2017, 11:42 AMval
is initialized with null
, isn't it going to be null
forever?nfrankel
09/27/2017, 11:45 AMvar
alsoqwert_ukg
09/27/2017, 11:46 AMqwert_ukg
09/27/2017, 11:46 AMqwert_ukg
09/27/2017, 11:47 AMopen class MyBean
can be injected too, or annotation needed ?enleur
09/27/2017, 11:48 AMopen
if you have @Component
annotation, it opens in compile timeqwert_ukg
09/27/2017, 11:49 AMdiesieben07
09/27/2017, 11:49 AMsdeleuze
09/27/2017, 12:54 PMsdeleuze
09/27/2017, 2:40 PMsdeleuze
09/27/2017, 2:41 PMsdeleuze
09/27/2017, 2:41 PMsdeleuze
09/27/2017, 2:46 PMsdeleuze
09/27/2017, 2:47 PMfitzoh
09/27/2017, 2:55 PMThanks to its great Java interoperability and to Kotlin extensions, Spring Framework Kotlin APIs leverage regular Java APIs and are additionally enhanced by a few Kotlin specific APIs available out of the box within Spring Framework 5 artifacts.
I’m struggling to figure out what the wording would be, but something the along the lines of a quick intro to what extensions functions are, then talking about how spring uses them to make using spring through kotlin more pleasant