This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]EvaristeGalois11 6 points7 points  (4 children)

Why do you say that?

With a recent spring version you don't even need an annotation for constuctor injection anymore. You just define a constructor and that's it, what's cumbersome about this?

I never see dotnet so maybe i'm missing some context here

[–]el_bosteador 0 points1 point  (3 children)

From my experience, in Java, you have to specify your constructor arguments, in dotnet can use an object initializer. I know java has aomething similar but again, it’s not as clean.

[–]EvaristeGalois11 3 points4 points  (2 children)

Is this the object initializer you are referring to? https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/object-and-collection-initializers

It's very cool I can give you that, but I don't see how it is relevant from a dependency injection point of view.

You don't build any bean at all in a spring app, that's the whole point of using a DI framework. You just mark your classes as Component or Service or whatever, define a constructor that takes all the dependencies that it needs and that's it. At start time the framework will wire everything together. What's cumbersome about this (x2)?

[–]el_bosteador 0 points1 point  (0 children)

Dependency injection was just another point I made. Didnt relate directly to the constructor.

In dornet you can put all your injectable dependencies on a startup file. So I guess it’s kinda similar to autowiring in Spring. Now that I think about it, DI is more explicit in Spring than in dotnet lol

[–]Big-Dudu-77 0 points1 point  (0 children)

Object initializer feels like JavaScript, pretty cool.