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

后端 未结 13 1720
失恋的感觉
失恋的感觉 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:36

    You could call ReportProgress from inside the doTask methods, that might make it look a little cleaner, instead you would just have:

    doTask1();
    doTask2();
    

    The reporting would be handled inside those methods.

    You could use AOP, but my brain screams KISS!!(Keep It Simple Stupid) in this case. If this is just a simple representation of something more complicated that you are dealing with, AOP could be an option.

提交回复
热议问题