Sunday, February 05, 2012

Inject Util Class with Google Guice vs static Methods?

http://stackoverflow.com/questions/4370683/inject-util-class-with-google-guice-vs-static-methods


It depends on the nature of your convert() method.
If it's something
  • simple
  • deterministic (i.e. doesn't depend on additional parameters)
  • have no side effects
  • is unlikely to change
  • etc
you can keep it as a static utility method.
Otherwise it's a good candidate for dependecy injection (you can rename it to ConversionService to make it more clear).

No comments: