lundi 17 octobre 2022

Design pattern to refactor lengthy task into a chain of unrelated classes

I currently have a long function that essentially carries out multiple different tasks sequentially (eg. it first clones a git repository, then edits some file in that repository, creates a new branch etc). What would be a clean way to refactor this code to a design pattern? I was thinking of creating a separate class for each sub class, and then chain these tasks together, but I am not sure if this is the best way of doing it. After reading more on the Chain of responsibility pattern, its principle is different to what i am trying to accomplish. My codebase is using python

Ideal outcome ->

MainClass calls classes
TaskA
TaskB
TaskC

Aucun commentaire:

Enregistrer un commentaire