Suppose you need to implement a toy VM(such for Brainfuck) where you have an external data structure representing the memory(a simple fixed array), and a ComputationalUnit object which cares of acting operations from a given set. What is the most efficient way to implement the last to make easy adding instruction, other than a giant switch calling the right method given the instruction. Assume instruction are read from a file or from user input as a String or char(brainfuck case) or by regret parsing.
If the answer involves a design pattern, I would be pleased to be redirected. Thanks to all.
NB: I’m asking for a structure, Java is not an issue