I'll start with a example of the problem, for which I'm wondering if there is a actual design pattern or how to build a good "architecture" for such problems.
- So lets say there is a resource a user can load, which has a few dependencies.
- These dependencies can be available on the users machine, available on a server, or not available at all.
- If a dependency is available it should be loaded - This is the default process.
- If a dependency is not available the user should be able to load this dependency from the server, if it is available there (maybe trough a global setting event automatically)
- If a dependency is not available on locally or on the server, the users should be able to provide it himself.
- Also the dependency can be a different version then the users should be able to say he wants to load a different version instead ....
So just to clarify i don't want a solution to this concret problem, I'm just wondering, is there a design pattern or something, to handle such problems?
To me it seams like a multi step procedure, where every of theses steps can fail, such failures can be fixed trough some interaction, also this fixes could fail which can possible fixed aswell.
What I am thinking right now is, to encapsulate these steps, like the loading of the dependency into own objects and have have each of these objects to have a execute function, also a state which determines the failure. These failure objects themselfs can be a step object, which if succesfully continues the whole process with the next step otherwise the whole process fails.
So I'm just wondering is there a good pattern to handle suche problems, or does this has to be a complete custom solution every time? I really won't to avoid having a complete customized solution with hundereds of if/else statements and after some time no one knows how to add additional conditions or change somethings because it is a huge mess.
I'm really curious what you guys have to say about this!
Aucun commentaire:
Enregistrer un commentaire