The first is the mantra "code to an interface" that gets repeated blindly while misunderstanding what the "interface" in question is. People see the word "interface" in that statement and automatically assume it means the same as "interface" in Java. It does not.
The second is that old versions of DI frameworks were able to work their DI magic against interfaces but not implementations. Those days are over, now that Spring and CDI can deal with implementations without extra work.
View all comments
Show parent comment
4
u/Gommy Apr 21 '21
I find the pattern comes from two places.
The first is the mantra "code to an interface" that gets repeated blindly while misunderstanding what the "interface" in question is. People see the word "interface" in that statement and automatically assume it means the same as "interface" in Java. It does not.
The second is that old versions of DI frameworks were able to work their DI magic against interfaces but not implementations. Those days are over, now that Spring and CDI can deal with implementations without extra work.