Some people say it's better to use dependency injection. Why is this?
I think it's better to have several global, easily accessible classes, rather than huge constructors.
Does this affect application speed?
The mix of the two will probably be the best.
The main advantage will be the decoupling, which will help with unit testing. It depends on how you code these "easily accessible classes".
. (class) , (interface). , , , ( ).
class
interface
, DI, , , , . : ? . , .
, static . - . .
static
?
, (Globals), . , Globals , .
, , DI - . .
"globals" DI. , , , singleton . -. , , , . , . , , , , , , , , , . : , , :
DI - , , , , , .. , DI , , โโDI : DI ( , ), c omposition, .
I think that at the top of this topic there is a very good summary of DI and how to use it correctly: Inject (DI) dependency "friendly" library
If you want to delve deeper into this topic, I can recommend Mark Siman's book, Dependency Injection in .NET.