I suppose I have got a design problem. So lets start from the beginning. This is what I want:
On one side there are ComboBoxes, which need to be filled, letting the user choose between functionality provided. On the other side this functionality has to be called, to fulfill its purpose.
I was thinking about something like this, scattered somewhere in the GUI:
// Parameter type describes what to do. This example shows that a CRC value
// shall be calculated. But it could be a quadratic formular or any other // calculation as well. So I assume parameter is of type IStrategy.
// And here I assume a further interface exist, lets say ICRCxx.
ChoiceProvider functionality = new ChoiceProvider(CRC16);
// Yes, I know about Items and binding. Method returns functionality
// provided by ICRCxx. For example just { "CRC32", "CRC16 CCITT" } will be
// returned at the moment.
string[] cellChoice_Of1stComboBox = functionality.GetCalculationNames();
bool functionality.SetCalculationName(string name);
// Here between start values can be chosen, necessary for the calculation.
// For example { "Ox0000", "Ox1D0F" } will be returned, if "CRC16 CCITT"
// has been selected above.
string[] cellChoice_Of2ndComboBox = functionality.GetCalculationVariants();
bool functionality.SetCalculationVariant(string name);
// to be displayed somewhere on GUI
string userResult = functionality.GetUserResult();
// Return type may vary depending on chosen calculation within.
var processResult = functionality.GetProcessResult();
// This is just a idea to be able to handle processResult.
// Maybe you have got a better idea. About that I had a struggle with
// generics.
Type processResultType = functionality.GetProcessType();
I am sorry, a lot of words will still follow.
I already got a class called ChoiceProvider. I made it generic, because first I tried it with recursion, to be able to combine as much ComboBoxes as I want. It is based on an dictionary>, as I am working with names. And T within IChoice>T> could be any kind of calculation.
ChoiceProvider is already working within an visitor pattern, being there the operator. But I failed let it work recursively before (without pattern).
Below visitor pattern (visited is TChoice, visitors are of IStrategy) is a strategy pattern to choose e.g. between CRC16 or CRC32 if ICRCxx has been passed through IStrategy. Operator is e.g. collecting calculations offered, so if ICRCxx has been passed, concrete strategy classes CRC16 and CRC32 will be collected as possible ComboBox choices.
But when passing data between methods Visit(IVisited... ) from class Do_Strategy (meaning "do calculate") to class Get_ProcessResult, I struggeled with generics as mentioned above. As I am not an expert with generics.
First I thought to ask you about my problem passing data from one class to another, struggling with generics or with something like this: How to force derived class to implement a static property or field?
But then I realized, that I could not find to a good question to find the right answer (technically or by design). So now I will just ask you about the design.
I now think visitor pattern makes it probably too complicated. I now think about just a main strategy pattern and a second strategy pattern below. But I wasted time. And I would like to be on a got path before I start with something new again. So I ask you.
...
Update - making it short:
Visitor pattern in my eyes, in my case is not the right way to go. I would like less code and more scalable.
I tried it with what I call a "closed functionality wired with GUI" (see above). Usually I get code where functionality and GUI are mixed up, where I have to find open functionality somewhere spread in the GUI.
- Are there already any simple solutions/code existing for my "closed purpose"?
- Are there useful keywords about which I should now? (like e.g. "ORM", "IQToolKit", ... for connecting OleDb to OOCode. In my case I want to connect functionality with e.g. ComboBoxes.)