Timeline for Is source code generation an anti-pattern?
Current License: CC BY-SA 3.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 17, 2020 at 12:55 | history | made wiki | Post Made Community Wiki by maple_shaft♦ | ||
| Dec 4, 2017 at 11:43 | comment | added | CodeMonkey | @kevincline what I meant was code that was based on some data from the database (could be constructed from it), but not the database itself. I.e. I have information about which signals I receive in Excel Table A. I have a Database B with information on these signals, etc. Now I want to have a class that accesses these signals. There's no connection to the database or the Excel sheet on the machine that runs the code. Using really complicated C++ Templating to generate this code at compile time, instead of a simple code generator. I'll pick codegen. | |
| Dec 1, 2017 at 8:11 | comment | added | kevin cline | @CodeMonkey: something like Ruby on Rails' ActiveRecord implementation comes to mind. There's no need to duplicate the database table schema in the code. Just map a class to a table and write business logic using the column names as properties. I can't imagine any sort of pattern that could be produced by a code generator that couldn't also be managed by Ruby meta-programming. C++ templates are also extremely powerful, albeit a bit arcane. Lisp macros are another powerful in-language meta-programming system. | |
| Nov 30, 2017 at 6:25 | comment | added | CodeMonkey | Not always. Sometimes you have one or more databases containing some definitions for e.g. signals on a bus. Then you want to pull this information together, maybe do some consistency checks and then write code that interfaces between the signals coming from the bus and the variables you expect to have in your code. If you can show me a language that has meta-programming that makes it easy to use some client provided Excel sheets, a database and other data-sources and creates the code I need, with some necessary checks on data validity and consistency, then by all means show me. | |
| Nov 29, 2017 at 18:01 | comment | added | Blrfl | It's also a workaround for having to write a full, down-to-native-object-code compiler for a more-expressive language. Generate C, let a compiler with a good optimizer take care of the rest. | |
| Nov 29, 2017 at 7:43 | history | answered | kevin cline | CC BY-SA 3.0 |