It really depends on the context. If you are writing a stand-alone Maths API, you can use static factories because the code will be less verbose, without installation, and possibly more efficient. If you need to access / provide remote dependency, JNDI / LDAP search or ESB messaging will work well. To enter your services / DAO / data sources into your typical corporate server code, you would be better off using one of the common DIs like Google Guice or Spring.
There is no single βbestβ solution in software development; it is always a compromise.
source share