Grokking Java Interview Questions
Vote

0% completed

​

Inversion of Control and Dependency Injection

class PriceService { private final Discount discount = new MemberDiscount(); int priceFor(int priceInCents) { return discount.apply(priceInCents); } }

This class works, but it can never use another discount. To sell with a coupon, or to test the class with a fixed discount, a developer must edit the second line. The class decides both how to use a discount and which discount exists.

Spring separates these two decisions

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content