I never used the javas-dependent injection function, so I read a few pages about it, and I still don't know about the duel between singleton and dependency injection.
Take a basic example: let's say that I am creating a small Java application using the MVC or MVVM pattern. I would start from the login page, asking for a username and password. These 2 information may be needed later in the application, so I will need to store them in a simple POJO, accessible from any kind of application.
What should I use then? Singleton Or should I insert a POJO constructor and get it if necessary with an injector (e.g. using Guice)?
Thank you for enlightening me :)
source
share