What do you think about
if(!DoSomething()) return;
In Clean Code this is viewed as violation of Command Query Separation. But how can we understand if something in command DoSomething() went wrong? What about sql command (ex: void Delete(Table))? How can we know if that table existed?
Thanks.
I agree with the comments from rObiwahn that you should check
CanDoSomethingbefore issuing a command ofDoSomething. In a pure CQRS environment,DoSomethingwould not return anything and if anything prevented Something from happening (not due to an exception, but a race condition or something else changing betweenCanDoSomethingandDoSomething), your domain would issue aDoSomethingWasInvalidevent (or something like that) which would allow your application to eventually become consistent.It may sound complex, but it really becomes pretty simple once you start breaking down the logic into small chunks and allow your application to embrace eventual consistency.
There are a lot of good resources on the DDD/CQRS group in google groups. A question like 'How do you tell the sender that a command failed?' is similar to your question a bit. People like Udi Dahan, Greg Young, Rinat Abdullin and others monitor that group and provide some really great answers. I'd recommend checking that out every now and then, too.
Hope this helps!