We often have objects that perform multi-part operations / tasks. An example would be updating the internal state of a list of objects based on a request from a file system and reading data from found files. These things are also often long, and they usually run in the background thread (we do a lot of Swing work, but I think these things apply to multi-level applications as well).
In such an operation, it is quite possible that part of the operation will fail (i.e., it will not be able to read 5 or 6 of the 5,000 files that we process). In this case, it would be impractical to throw an exception, but we still want to provide the user with feedback on what did not happen, etc.
We always used ad-hoc approaches (for example, logging or an operation that returns an exception list), but I decided to hack and really think about it.
One motivating concept is validation (jgoodies have a good implementation). The idea here is that when you check values ββin a form or data structure, you create a ValidationResults object that can contain ValidationResult objects. Each ValidationResult has a state (OK, WARN, ERROR), as well as descriptive text (and, if necessary, other things).
I am very tempted to simply use the Validation framework as is for the results of the task.
Another option is to show the current state of the result of the task operation as a bound property (possibly using the GlazedLists event list).
, - - / , , (.. WARN)?
:
. , , Eclipse. , Eclipse , " , ", , .
.
, , :
1 b/c .
2 ad-hoc . , , , .
, " " ( , - ), - .
/, - .
, " ", ? , ? ?
- , - , ( )?