Skip to content

Instantly share code, notes, and snippets.

@jianwu
Last active June 19, 2019 18:26
Embed
What would you like to do?
A typical component in DI every approach
public class OderSericeImpl implement OrderService {
private final ShoppingCartService cartService;
private final PricingService pricingService;
private final InventoryService inventoryService;
private final UserSession userSession;
private final TimeProvider timeProvider;
// ... and many more, this list will keep increasing when more requirements added
public OrderService(
ShoppingCartService cartService,
PricingService pricingService,
InventoryService inventoryService,
UserSession userSession,
TimeProvider timeProvider) {
this.cartService = cartService;
this.pricingService = pricingService;
// ....
}
public CreateOrderResponse createOrder(CreateOrderRequest req) {
// ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment