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

后端 未结 13 1495
失恋的感觉
失恋的感觉 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-08 09:52

    It would be natural to have the reporting inside the doTask() calls.
    Typically the reporter would be a singleton that all the objects sent messages to and a reporter class was reponsible for deciding if and where to show it - statusbar, log file, stderr etc.

提交回复
热议问题