- Year not given · 3 marks
Short note: generator-based reuse
Short answer
Generator-based reuse captures domain knowledge in a program generator; developers write a domain-oriented description and the generator produces code automatically. Examples include yacc/lex, CASE code generators, and GUI builders. It is very productive in narrow, well-understood domains but generated code may be inefficient and the generator itself is expensive to build.
Write a short note on generator-based reuse.
Generator-based reuse is an approach in which reusable knowledge is captured in a program generator instead of in code components. The developer describes what is needed in a domain-oriented language or through an interactive tool, and the generator automatically produces the program code.
+-------------+ +-----------+ +-----------+
| Application |--->| Program |--->| Generated |
| description | | generator | | program |
+-------------+ +-----------+ +-----------+
^ ^
| |
+-------------+ +--------------+
| Application | | Extra hand- |
| domain | | written code |
| knowledge | | (if needed) |
+-------------+ +--------------+
Examples
- Application generators for business data processing (report and form generators).
- Parser and lexical analyser generators such as yacc and lex, which generate a parser from a grammar.
- Code generators in CASE tools that produce code from UML/design models.
- GUI builders that generate interface code from drag-and-drop screens.
Advantages
- Very cost-effective: a short description produces a lot of correct code.
- Easier for domain experts and end-users than writing code.
- Generated code is consistent and follows standards.
Disadvantages
- Applicable only to well-understood, limited domains where abstractions can be clearly mapped to code.
- Generated code may be less efficient and hard to read or modify by hand.
- Building the generator itself is expensive.
✓ Answer checked by Claude Sonnet 5.5
Related questions
- Reuse framework versus program generator · Software Engineering, chapter 5
- Microprocessor relaying via generator field current · Switchgear and Protection, chapter 8
- Reactance diagram 1000 kVA base and generator currents · Power System Analysis I, chapter 3