Having written some code generation in perl, generating C, Java, shell, among others, all from the same source data, I'm going to say that code generation and cut&paste don't belong together. Mind you, that may be because I have a fully-automated code generator (i.e., runs in the nightly builds) rather than a one-off code generation where we check in the generated code rather than the code generator.
Making changes to one output instead of another is trivial. Adding data to the input is trivial (we store our input data in an XML-like format). If there's a different type of data that needs to be fed through from input to output, well, that depends on the flexibility of the code. In my case, I'd have to add probably about 3-6 lines of code to handle it one new type of data, because the underlying code base is simply that flexible. Tagging with comments is not needed - it's built every night. Getting the build system to recognise it is easy: make already can take arbitrary commands as a way of generating intermediate files (i.e., "C" code) - the fun part is labelling all the pre-reqs so make knows when to rebuild it.
Oh, and hand modification of generated code is verbotten. Absolutely. If it's not a checked-in file, it can't be modified. Ever.
In reply to Re^2: Hierarchy of code reuse by flexibility
by Tanktalus
in thread Hierarchy of code reuse by flexibility
by zby
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |