Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is learning Dependency Injection worth it for someone that usually only does small projects(5-20k lines)?

I just usually do applications for myself as a hobby. It looks like DI frameworks have a big momentum in the community, so I thought maybe I should learn it to improve my coding skills. From what I understand, it seems to be geared more towards big projects. Is it still a good idea to use it for example in a 5k lines project?

like image 374
devoured elysium Avatar asked May 16 '10 13:05

devoured elysium


2 Answers

I use DI for all code I write, no matter the size.

However, you should be aware that DI does not require a DI Container. A DI Container certainly helps (especially on big projects), but you can also write container-agnostic code using DI principles.

The size of the code base doesn't really matter. What matters is maintainability. DI enables loose coupling that again enables maintainability. For all but one-off, throw-away projects, that's valuable.

like image 165
Mark Seemann Avatar answered Nov 27 '22 13:11

Mark Seemann


Yes - dependency injection promotes loose coupling and testability which is useful for a project of any size, and the overhead of configuration is relatively small.

like image 42
Lee Avatar answered Nov 27 '22 15:11

Lee