Hi!
I want to use dependency injection pattern in my assignment. So that my Data class wild contain such constructor
during startup of the application all dependencies wold be injected, like this:
and finally my DataAccessObjectImpl (please, notice that it's constructor would be private):
As you can see only one DAO instance would be created for one db file.
(I also plain to add ShutdownHook (Runtime.getRuntime().addShutdownHook(...)) during startup on order to close RandomAccessFile during shutdown, and it will use the same getInstance(..) method of DataAccessObjectImpl to receive appropriate DAO instance)
And here are my questions to you:
- What do you think about using dependencies injection in current situation? Do you think that Sun assessors will accept such solution (I afraid because in this case I don't have defult constructor in Data class)?
- Do you think it's good Idea to use getInstance() method in DAO, or it's better to instantiate DAO directly in the Data class constructor?
- Do you think that provided solution is too complicated and would cause frustrations to junior java developer?
I would be happy to know your opinion about this solution and your comment are highly appreciated!
Thank you in advance!