<p>I am implementing long running processes that require to a process bar - or progress percentage - to be displayed. The overall logic of the long running process is complex (various paged data retrieval), and as a result, I end up hardcoding lots of percentages in various places within the code.</p>

<p>What are considered as the best design patterns when it comes to update a completion percentage?</p>

If you know in advance the 'length' of the task you're going to perform, and have a way of knowing how far along you are, you should let the bar determine the percentage. For example, if you have to process a known number of files, give this number to the progress bar on construction. Then, during the process either the bar can poll the process, or the process can tell the bar how far along it is (in number of files). The bar can compute the percentage from these two values. This is how the
standard progress bar in Java
works.