Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce automatic dependency injection #192

Open
hannotify opened this issue Mar 27, 2023 · 2 comments
Open

Introduce automatic dependency injection #192

hannotify opened this issue Mar 27, 2023 · 2 comments
Milestone

Comments

@hannotify
Copy link
Contributor

hannotify commented Mar 27, 2023

When supporting the "Copy to clipboard" behaviour with a command-line option (in #184), I discovered that there is currently no easy way to make the value of such an option available at an arbitrary code location. This results in passing a parameter value through multiple layers of interfaces and classes, which is inflexible to say the least.

What if we would introduce a light-weight DI framework (like Dagger or ActiveJ Inject), so that more features can be built that are controlled by a command-line option in a more elegant way?

@mthmulders
Copy link
Owner

I've heard about Dagger before, ActiveJ Inject is new to me.

As far as I can see, Dagger 2.45 seems to be more widely used than ActiveJ Inject.

Given that I prefer to distribute MCS as a native executable, I think it's important that either option plays well with GraalVM's native executable building. Ideally, I'd like to see a reflectionless approach, as I believe it will work faster.

  • Judging from this blog, Dagger 2 should work out-of-the-box in a native executable - because it completely works at compile time.
  • From the ActiveJ Inject docs, it seems it needs some reflection configuration before it can be used in a native executable.

It's not even close to a thorough comparison, but from these two parameters, I'm tempted to give Dagger 2 the benefit of the doubt. What do you think?

@hannotify
Copy link
Contributor Author

Didn't consider the usage of both options, but Dagger seems a solid choice based on that criterium!

@mthmulders mthmulders added this to the 1.0 milestone Aug 8, 2024
@mthmulders mthmulders changed the title mcs could benefit from introducing a (lightweight) DI framework Introduce automatic dependency injection Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants