Skip to content

How to handle component dependencies? #57

Answered by arkivanov
brahyam asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for such a good question! First of all, personally I'm trying to avoid any DI frameworks. It might be opinionated, but I believe that DI frameworks hide the excessive complexity of the code. When I catch myself willing to add a DI framework, it is a sign for me that the code is coupled and complex.

A solution for this is usually to decompose the code by smaller peaces (e.g. modules). This is actually one of the primary purposes of Decompose!

So I would certainly go with the approach #1 or #2. I would pass all the dependencies via constructors. Except, probably, the cases with the most commonly used dependencies, like Tracker or HttpClient. Such common things I would likely add to t…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by brahyam
Comment options

You must be logged in to vote
1 reply
@arkivanov
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants