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

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -