This might be a naive question. I\'m currently learning the Spring framework and dependency injection. While the basic principle of DI is rather easy to grasp, it\'s
Granted, this is a contrieved example, and with more complex object relationships it might be more efficient to stash up an XML file than writing it programmatically, but surely there must be more to it than that?
I think it makes more sense to put the "wiring up" in a configuration file rather than doing it manually in code for several reasons:
sawmill to use a different instance of Saw) can simply be made to the external (XML) file and do not require changing code, re-compiling, re-deploying, etc.Controller class which gets a Service class which contains your business logic, which uses a DAO to obtain Saws from the database, which gets a DataSource injected into it, etc.), manually wiring up the collaborators is tedious and requires a few dozen lines of code that do nothing but wiring up.