How to make the cleanest code when reporting progress to a user?

后端 未结 13 1494
失恋的感觉
失恋的感觉 2021-02-08 09:10

I\'ve struggled for the last couple of months to come up with some clean code to report progress to a user. Everything always seems to boil down to:

ReportProgr         


        
13条回答
  •  无人及你
    2021-02-08 09:52

    Assuming the pattern in what you're doing is:

    • log task start
    • do task
    • log task end

    you can have a "Task" class (parent for all your tasks), whose do() method is subclassed and automatically logs start and end of task.

    Just an idea.

提交回复
热议问题