Let’s stick to your order example. Let’s assume the client continuously shows the grand total of an order. And let’s assume adding up these numbers is too complicated to have this code duplicated.
You’d just have to create an OrderTotalsCalculationsService that does the job for you. It would have a method with a signature like “OrderTotals calculateOrderTotals(List items, ShippingType shippingType)”. The parameters and result of this method should not be command-specific objects. In my projects, I always have a simple rule: an object can only be shared between command/query and UI side if it is immutable. And it should also “make sense” given the domain.
Since OrderTotalsCalculationsService is a Domain Service, it is part of the domain. It is also “side effect free”. Which means that invoking this method will not change the applications’ state. This makes it safe to be shared around the application, just like you share any other objects.
Another way to do it, is by implementing it on the query side. But, that will require your app to invoke a server component each time something changes. If you have a rich client, that might give some unwanted overhead. In that case, the OrderTotalsCalculationsService will only live on the server. It will still be used by both the command and the query side.
For an explanation of (Domain) Service: http://www.domaindrivendesign.org/node/125
Does this clarify?