mthmulders / mcs

Search the Maven Central Repository from your command line!

Home Page:https://maarten.mulders.it/projects/mcs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mcs could benefit from introducing a (lightweight) DI framework

hannotify opened this issue · comments

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?

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?

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