I am translating text files from one set of definitions to another, and I solved the problem by writing a small parser. After I defined the character, I end up in a case case, which decides which translation procedure to call depending on which user has chosen the input option (these are codes that mean different things on different machines).
I use several input formats and convert them to one output format, more than 400 unique characters.
The problem is that since this project has grown from several simple translations, each in its own header file, to dozens or more input formats, it becomes cumbersome to maintain. Each of these header files contains a monster switch statement that outputs the corresponding output. It all works, but it actually seems awkward.
Will I solve the maintainability problem by creating mapping tables (i.e., a 2nd array containing input and output characters) for each input device, and using a general translation procedure that takes tables as input? Is there a better design I should consider?
source share