Implement efficient method invocation order possibilities

51 views Asked by At

I got several methods which does some operations. Let's call these methods for example x,y,z,w.

The user is suppose to let me know somehow the order of invocation of the methods. for example, he can choose to call: x(); z(); w(); y(); or some other possibility.

The question is, how can I implement something like that efficiently considering that every combination can be possible? I want to know implementation ways, and how to let the user choose the order. (maybe an Enum for example? but them will the enum be with values of xyzw, xzyw etc. which will have many possibilities?)

1

There are 1 answers

0
CodeMonkey On BEST ANSWER

What I eventually did was making a Dictionary<string, Action> that maps from the name of the string to its method. Since we're talking about a system with a GUI, I've also added the user some ComboBoxes with the available options (the string valus of the keys from the dictionary) and he could choose the order he wantes. Then I just iterate his choices and activate the method accordingly.