Skip to content

Instantly share code, notes, and snippets.

@jianwu
Last active June 19, 2019 18:26
Show Gist options
  • Save jianwu/0511f117fb1a322759daebab34b9d4ff to your computer and use it in GitHub Desktop.
Save jianwu/0511f117fb1a322759daebab34b9d4ff to your computer and use it in GitHub Desktop.
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