I read a lot about IoC and DI, but I'm not sure that you will gain much by using them in most situations.
If you write code that requires plug-in components, then yes, I see the value. But if you don’t do this, I wonder if the change in class dependency to interface really gets you anything but more typing.
In some cases, I can see where IoC and DI help with mockery, but if you are not using Mocking or TDD, then what is the value? Is this the case of YAGNI?
, - , .
-, DI ( SOLID), TDD. , TDD, , , , .
, - , . fooobar.com/questions/34162/....
, , , , . , , SRP.
, , . (.. ), , . , .
, . YAGNI, , , . - , .
DI, . . , , , . , ( ), . , , Singleton, .
, . , (- + ).
: , .
DI . , . , , , , .
- , , .
, , , . .
DI , . , DI, . - , , . .
.
Java, ( 50 ).
, . , - , . , , , . , .
The second component that I developed from scratch, and used dependency injection (not knowing about it at that time). That is, I had one factory, which built all the objects and introduced them in order to know the base. Adding another dependency was simple, just add it to the factory constructor and object constructor (or add an installer to avoid loops). No need to touch unrelated code.
Source: https://habr.com/ru/post/1705106/More articles:SMTP Message Inspection IIS - iisКак получить макросы, определенные в книге Excel - vbaEmbed HTML files in other HTML pages - htmlUsing delegates and announcing events - event-handlingTable reel / Eager Spool - optimizationFinding static class attributes in Python - pythonHow to determine if a function is defined in php - phpUsing the Enterprise Library Logging Application Block in NHibernate - nhibernateItem level permissions (edit only their own, but read all) - sharepointWhat are the most active Ruby forums / blogs on the Internet? - ruby | fooobar.comAll Articles