wizard that create code in multiple programming languages
-
03-07-2019 - |
Question
as part of our application i need to build component that will output code in php and asp that have the same functionality ( and maybe latter jsp ) . how can i design this kind of component to be generic as possible ?
Solution
You need to be able to create a parse tree out of all input languages.
For each output language, you will need to create a set of tree transforming grammar.
You may also require a runtime library to help translate routines that are not available in your output language.
OTHER TIPS
I would personally go with the Strategy Pattern. You could have a master code maker class and instantiate it with a strategy.
PHPCodeStrategy ASPCodeStrategy
Then each would have a method called execute maybe. Bu then you could add further strategies down the line and extend your application.
Andrew