Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You can initialize your object with main. But if you are reusing some implementation in multiple object you will start to repeat yourself a lot in the initialization.

A DI framework allows you to set conventions to avoid repeating yourself in the initialization phase. (ie if a class requires a parameter 'foo', look for a class named 'FooImpl').



I guess this makes sense, but DRYing up my object graph assembly doesn’t seem particularly important, and when it gets excessive I’d just create helper functions. This way everyone who touches my code (including the poor souls who operate it downstream) don’t need to understand my DI framework (how the DSL files are loaded and mapped onto code) for even the slightest debugging.


Could you give a more concrete example? How would you "repeat" yourself?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: