I'm trying to find a useful design pattern that simulates something like this following:
DoThis()->ThenThis()->FinallyDoThis() then print "Hello world"
ThenThis()
doesn't run unless DoThis()
passes. And FinallyDoThis()
won't run unless ThenThis()
and DoThis()
both pass. If all the methods methods pass, then it prints "Hello world".
Is there an existing design pattern that would fit nicely to this? I've been investigating the usage of monads, but not sure if they are applicable to this case.