Похожие чаты

About reason number 3 i does not care which implemention

is used in any way because
if i use DI or not is the same because i using the implemention of the interface so it does not matter how i do it

in the DI way:
@AutoWired
@Qualifier("someImpl")
Interface inter;

abd if i want to change:
@AutoWired
@Qualifier("otherImpl")
Interface inter;

right?

the regular way:
Interface inter = new Impl();

if i want to change:
Interface inter = new Other();

so what are the differences???

1 ответов

7 просмотров

Well, in this situation DI vs non-DI may look similar. But there are other examples in which non-DI approach sucks. For example, what if you have to deal with conditionally created beans, i.e. in your development environment you use one implementation and in production you want to use another. Or what if you had only one implementation of something in your application but then decided to switch to something cooler which implements the same interface. And this "something" is used allover your application. If you didn't have DI, then you'd have to go through all of your components to switch to new dependency. However if you did have DI then you would need to replace the old dependency only in one place

Похожие вопросы

Обсуждают сегодня

Ясн. Но я всеравно к кедам отношусь с опасением. Чисто субьективное кедосозерцание. Что касаемо "восторга изяшности кед" так и не вкурил, хотя много слышал, пока не поставил с...
Артем Записной
30
Такой вопросец - есть функция function MySuperDuperConcat(const a: array of AnsiString): AnsiString; Как мне в её теле сделать вот так? Result:=Concat(a); А не грустный вариан...
notme
15
type TObj = object procedure Init; virtual; end; TObj1 = object(TObj) procedure Init; override; end; procedure TObj1.Init; begin inherited; end; procedur...
Alexander 👋
29
They keep hyping $FUN but where's the progress? 🙄
Noah Noure
23
Есть какой-нибудь для Delphi/FPC T*Compression(Decompression)Stream на базе LZ4/Zstd/любой другой быстрый(и хорошо сжимающий) алгоритм А ещё лучше в pure pascal А ещё лучше од...
notme
48
Btw guys very stupid question but i haven't researchd so js asking you pros . Can ltc be traced too? Literally point to pint to the user? And getting the banks blocked ? Exch...
20
А чем вам питонисты не угодили?😂
.
79
Hey guys, did you see the new announcement about $Fun? 🔥
Filip Murphy
55
How can a minority hashrate chain defend from a fork-hopping ASIC miner? The problem: 1. A miner comes into your network, and mines at 60-70% hashrate. 2. After some time, th...
Kishniev
13
yeap, thanks guys for response, but I really like to understand does a pool created on curve.fi has the option or api or I can call a function of a smart contract to set excha...
Oleg Karoza
11
Карта сайта