766
Senior devs... (thelemmy.club)
you are viewing a single comment's thread
view the rest of the comments
[-] aaaaaaaaargh@feddit.org 2 points 1 week ago

I think you're confusing composition with aggregation. DI can't be composition because the injected object is shared/borrowed, strong composition on the other hand requires the object to be owned. A composed child does not exist without its parent.

[-] RedFrank24@piefed.social 1 points 1 week ago* (last edited 1 week ago)

Only if you're going by the strict UML definition of composition, which doesn't really apply here, since the industry has moved on a bit since UML was king.

Either way, you can use DI to do composition in the strictest UML way, provided every single dependency is transient and creates a new instance every single time. Even then though, when most devs talk about composition, they aren't referring to the strict UML definition.

[-] aaaaaaaaargh@feddit.org 1 points 1 week ago

Yeah but I was talking about the opposite. I can clearly spot composition in many frontend framework such as react or flutter but e.g. spring DI is a different thing to me.

this post was submitted on 30 Jan 2026
766 points (97.1% liked)

Programmer Humor

29565 readers
570 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS