I'm designing a very big system that I will implement with C# and .NET Framework 4.6.2 (but I think this is not relevant for my question).
This system will have modules that I can use it in one computer or not. For example, if I'm using my system to track datamatrix read by a camera, I will use a module to read datamatrix, but in another installation I'm not going to install that module because I'm not going to read datamatrix.
In a few words, my system will be a windows desktop application with a lot of user controls that I can use to manage some functions if those functions are available.
All of those modules could save statistics. For example, in the module with the camera to read datamatrix I would like to store the number of datamatrix, how many I read in a minute, wrongs datamatrix read, etc. This is not the function for this module, so I need to create another module to manage this statistics.
Sometimes I will use statistics, but sometimes no. So, I need a mechanism to prepare all modules to use the statistics modules:
- Add a call to a method of statistics' module to save data.
- Add a way to plug the statistics' module to another module and don't do anything else to use it.
In a nutshell, add a way to use statistics module if I have "plug-in" it into the datamatrix module, and don't use if I haven't plug-in it.
I need to do something to prepare datamatrix module to use statistics module if I have plugged-in, but don't throw any error if I haven't plugged-in.
I think I need to implement an interface for statistics module and a way to add an instance of that module to datamatrix module. And, on datamatrix module, check if statistics module if available before use it.
What do you think? Is there a pattern to make this?
Aucun commentaire:
Enregistrer un commentaire