In DDD, one of the strategic patterns is the use of the ubiquitous language in code. So, in your particular case, the class methods should be named according to what they do, for example, Product::changeTitleor Priduct::changePrice:
, . , , :
class ProductService {
public void changeProductPrice(long productId, double newPrice) {
Product product = productRepository.findOne(productId);
product.changePrice(product, newPrice);
productRepository.save(product);
}
}
.
- :
class ProductCommandHandler {
public void handleChangeProductPrice(ChangeProductPrice command) {
Product product = productRepository.findOne(command.getAggregateId ());
product.handleChangeProductPrice(command);
productRepository.save(product);
}
}
CQRS + Event sourcing, Application layer, command handler, , , Event store. .