jeudi 19 décembre 2019

Best design pattern for a step by step operations

I'm working on a step by step operations code that retrieve some data and execute steps operations, if some of the steps fails the process stops and in the next execution check the step value to resume the operation from it.

What Design pattern meet this scenario?

Following some pseudocode as example:

step = get_server_step()

if not step:
    try:
        update_server_step('1')
        step = '1'
    except Exception:
        raise Exception('Stop execution')

if step == '1':
    try:
        update_server_step('2')
        step = '2'
    except Exception:
        raise Exception('Stop execution')

if step == '2':
    try:
        update_server_step('3')
    except Exception:
        raise Exception('Stop execution')

approve_process()

Aucun commentaire:

Enregistrer un commentaire