Passive generators are used for convenience. But active generators are required if we want to follow the DRY principle. An active generator takes a single piece of information in one format and converts it into different formats. The generated code is disposable. The code is generated as needed by the generator. Whenever we find ourself trying to get two disparate environments to work together, we should consider using active code generators.
Active generators can be used in situations when we have multiple programming languages in a single application. In order to communicate, each code base will need some information in common, like data structures, message formats etc. Sometimes, we can parse the information out of the source files of one language and use it to generate code in a second language.
Code generators need not be complex. Keep the input format simple, and the code generator becomes simple.
Code generators need not generate code.
It can be used to generate any text that is required in our project.
- summary of Code Generators, from The Pragmatic Programmer: from Journeyman to Master
Active generators can be used in situations when we have multiple programming languages in a single application. In order to communicate, each code base will need some information in common, like data structures, message formats etc. Sometimes, we can parse the information out of the source files of one language and use it to generate code in a second language.
Code generators need not be complex. Keep the input format simple, and the code generator becomes simple.
Code generators need not generate code.
It can be used to generate any text that is required in our project.
- summary of Code Generators, from The Pragmatic Programmer: from Journeyman to Master
No comments:
Post a Comment