Java, Unit Testing, Legacy Code, Programming, Technology.
new PaymentProcessor(); public void processOrder(Order order) { paymentProcessor.process(order); } } Refactor this class to use dependency injection: public class OrderService { private final PaymentProcessor paymentProcessor; public OrderService(PaymentProcessor paymentProcessor) {