The discussion of api design is quite interesting, but apt to guess :-)
Some random thoughts at the end of the week:
The basic SwingWorker process model allows you to do something in the background and maintain reporting of both the intermediate and final result / s back to the EDT.
it is intended for a subclass (as @trashgod already emphasized), at the same time it is trying to minimize the efforts required for this: the state and progress are fully defined and implemented by convenient properties intended for use as,
therefore, api doc rules, which clearly indicate the permissible values ββof the process of the associated property, which are in the range 0 ... 100, incusively. No ambiguity, nothing can be changed in user implementations. Percentage is the most common use case, keeping it out of the box is a reasonable thing.
To present intermediate results in coordinates other than percent, the intented way is to implement the process (..). It depends on the user implicating what it is doing, it can launch a user defined property or populate a view model directly or ... no matter what
Finally, an example tutorial is just an example. Furthermore, this is incompatible in itself: a description describing the task.getLenghtOfTask method, which is not implemented in the custom swingworker. My (wild) guess is that the sample text is still based on an older version that could support arbitrary values.
To answer the question (my 0.02Euro cents :-) - nothing wrong with the design, this is a balanced basic implication that handles common use cases outside the box and at the same time flexible enough to make the more advanced requirement easy to implement.
for updating when one piece of information is available
you cannot completely control the granularity of reporting: all you can do is determine the unit of the smallest fragment, and then expect to get one or more of these smallest coins.
kleopatra
source share