When should I use Dependency Injection and when utility methods?
Posted
by Roman
on Stack Overflow
See other posts from Stack Overflow
or by Roman
Published on 2010-05-03T14:49:40Z
Indexed on
2010/05/03
14:58 UTC
Read the original article
Hit count: 349
I have a Java EE project with Spring IoC container.
I've just found in Utils
class static method sendMail(long list of params)
. I don't know why but I feel that it would look better if we had separate class (Spring bean with singleton scope) which will be responsible for sending email. But I can't find any arguments which can prove my position.
So, are there any pros (or cons) in using DI in this (rather general) situation?
© Stack Overflow or respective owner