mthmulders / mcs

Search the Maven Central Repository from your command line!
https://maarten.mulders.it/projects/mcs/
MIT License
177 stars 23 forks source link

Introduce automatic dependency injection #192

Open hannotify opened 1 year ago

hannotify commented 1 year ago

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 commented 1 year ago

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.

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 commented 1 year ago

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