I'm a bit of a DI newbie, so forgive me if this is the wrong approach or a silly question.
Let's say I have a form which creates/updates an order, and I know it's going to need to retrieve a list of products and customers to display. I want to pass in the Order object that it's editing, but I also want to inject the ProductsService and CustomersService as dependencies.
So I will want my IoC container (whichever one I go with) to supply the services, but it'll be up to the calling code to supply the Order object to edit.
Should I declare the constructor as taking the Order object as the first parameter and the ProductsService and CustomersService after that, eg:
public OrderForm(Order order, ProductsService prodsSvc, CustomersService custsSvc)
... or should the dependencies come first and the Order object last, eg:
public OrderForm(ProductsService prodsSvc, CustomersService custsSvc, Order order)
Does it matter? Does it depend on which IoC container I use? Or is there a "better" way?
I disagree with @aku's answer.
I think what you're doing is fine and there are also other ways to do it that are no more or less right. For instance, one may question whether this object should be depending on services in the first place.
Regardless of DI, I feel it is helpful to clarify in your mind at least the kind of state each object holds, such as the real state (Order), derived state (if any), and dependencies (services):
http://tech.puredanger.com/2007/09/18/spelunking/
On any constructor or method, I prefer the real data to be passed first and dependencies or external stuff to be passed last. So in your example I'd prefer the first.