When communicating concurrency conflicts to your application layer, is there an alternative to using exceptions that also respects the principle of Command-Query Separation, or are exceptions the best mechanism we have (in languages that support exceptions)?
In the bowels of my application, I have optimistic locking logic that executes a few layers down when I call certain high-level methods, e.g. (in my case, I'm using a custom data access layer, though I'm certainly open to hearing how ORM implementations do this). High level method calls that the application interacts with look like this:
// 'data' is just a placeholder for multiple parameters, including something
// that contains row version information
void Customer.UpdateInformation(object data);
I need to be able to tell users of a web application when someone else has updated the data they're working on.
I'd rather not return a value from methods that change data. So in the past, I've thrown exceptions (similar to the .NET data adapter API, which throws a DBConcurrencyException when it detects conflicts), but concurrency conflicts are not, in some common-sense way, exceptional. They're a fact of life: a predictable, expected part of the application's workflow. Do they qualify as exogenous exceptions, in Eric Lippert's taxonomy?