So, imagine spaghetti code. A task should go from 1 to 2 then to 3, etc. If a task breaks, abort the program. I can write this in a procedural manner, but would like to know if there is a design pattern for this.
I looked at Chain of Responsibility, but it does not fit. I already know which process should handle each task. Master/Worker does not fit either because it needs to be processed step by step.
Concrete problem at hand is - allow user to upload an Excel file, compare file to the database table structure, then update the database.
Steps would be: 1. Upload the file - verify that file is uploaded, if not, return. 2. Verify that file is an excel file, if not, return. 3. Read file into a datatable, if error, return. 4. Get datatabe from the database, if error, return. 5. Load each datatable into respective 2D arrays, if error, return. 6. Compare if each array has same number of columns, if error, return. etc etc etc...
Is there a way to use a design pattern for this? Thanks.
Aucun commentaire:
Enregistrer un commentaire