Why there's no configuration file at all for dependency injection with Google Guice?

后端 未结 6 2277
生来不讨喜
生来不讨喜 2021-02-19 23:51

I am checking out Google Guice as DI framework but I am a bit puzzled: why there\'s no configuration file at all?

I found a partial explanation on this question but it i

6条回答
  •  别那么骄傲
    2021-02-20 00:43

    The configuration is in the code instead of config files, which is a valid decision for many scenarios.

    Yes, it means that you have to rebuild (possibly just the modules) if you want to release a different way of plumbing your application - although of course you could still get some configuration values from command-line arguments, properties files etc if you want to.

    If you regularly need to change your application plumbing and don't want to redeploy anything but a single file, Guice may not be for you. If on the other hand your main reason for using DI is to make your code clearer, and in production you'll always really use the same plumbing (or close enough) then Guice is a good option - there are often bits of logic you want to use when sorting out the plumbing anyway, and components which are generally hard to describe/construct declaratively.

    Different DI frameworks have different benefits and trade-offs - use whichever one is most suitable for your application.

提交回复
热议问题