java - global object for returning spring singletons -


is there wrong design point of view having global object returns singletons spring context?

i started work @ new place, , daos accessed via global object called daoutils, each dao gets singleton dao bean spring context. if want save purchase order, example, say

daoutils.getpurchaseorderdao().savepurchaseorder(po);

or that.

i've been used injecting daos required each class needs them, , shocked me little. there wrong design point of view, , if can explain why bad idea?

i can see makes unit testing difficult, because there's no way stop code calling actual daoutils class..? guess described problem caused tight coupling?

this bad design pattern since cannot substitute daoutils else e.g. testing purposes.

spring uses dependency injection , that's best way retrieve dao instance.


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -