Which design pattern to use for pre-process process and post-process task

853 Views Asked by At

I am working on one migration engine to migrate data from older system to newer system. it is divided into 3 steps.

  1. first getting the data from older tables.
  2. prepare the request body to insert into new tables via APIs
  3. post processing steps.

Which design pattern to use here?

I was thinking of using builder pattern

In the second step where i am doing multiple API calls for inserting data into new tables. this has some order. If API call fail in between then need to redo all previous API calls. kind of rollbacking mechanism. How can i achieve that?

2

There are 2 best solutions below

0
On

I think you might want to go for a Pipe-Filter Pattern here as an overall design. What you describe is pretty much described here.

4
On

Here you already have pre-defined and definite steps to perform. In this case template design pattern works well.

Sequence of calling steps are fixed and Responsibility of each steps can be seggregated into separate classes and finally can be linked on template management class.

Refer this link - https://refactoring.guru/design-patterns/template-method