S
S
Sergey Belyaev2017-01-06 01:52:27
Design patterns
Sergey Belyaev, 2017-01-06 01:52:27

Do you use Dependency Injection in your work?

DI allows you to use loose coupling, but at the same time complicates the code. Do you use DI in your work or prefer to keep it simple, or did someone else (team, past developer) make this decision for you? And why do you or don't you use it?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
Rou1997, 2017-01-06
@Rou1997

При проектировании применяю в разумных пределах, когда есть возможность.
Главное - замедляет разработку, как и прочие меры, направленные на повышение гибкости.

Станислав Силин, 2017-01-06
@byme

What is the advantage of Dependency Injection over using the new operator?

Z
Zelimkhan Beltoev, 2017-01-06
@Beltoev

Do you use DI in your work or prefer to keep it simple, or did someone else (team, past developer) make this decision for you?

We use it at work. Historically, they wrote their own container there, which remains the same.
I use DryIoc in my projects.
I use it because it:
The main thing here is not to succumb to the temptation and not reduce all the pros to cons by starting to use the same service locator

A
Alexander Ivanov, 2017-01-13
@DoctorStein

but it complicates the code

I do not agree. DI assumes that the code is divided into modules. The use of independent modules for various tasks simplifies both the code and its future support. And complex code can always be written if desired, and DI is not to blame here.
On the issue - we use it, including according to my decisions. We have already written about the benefits here, but it is also important for us, for example, that on the Continous Integration server, changing one library does not lead to rebuilding fifty others that depend on it directly or indirectly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question