3 ms·
> I had a collection of scrips and macros that generated most of my code straight out of the functional design. Scripts that generated code? As in, code that w
by jroseattle 13y ago
> I had a collection of scrips and macros that generated most of my code straight out of the functional design.
Scripts that generated code? As in, code that would be compiled and executed?
- mcv 13y agoYes. It was Visual C++. Most of it was piles of conditions and generating texts based on that. It was all specified in excruciating detail in the functional design, which I received as a word document. I believe I had a word macro that selected what I needed and did some formatting or something, and then probably some regexp replaces to turn it into actual C++ code. It worked very well, and because the project had a number of iterations where we'd implement yet another kind of insurance based on the same kind of FD, I could reuse it quite a lot. But my first project there was euro-proofing some code. I had to dig through the code and figure out which numbers could represent money amounts. Another programmer was doing this by hand, but I figured it should be possible to automate it (there was a lot of code). After unsuccessfully trying to figure out a regexp to match what I needed, I ended up writing my own not-quite-finite state engine to parse the code and insert comments near all the suspicious numbers.
- jroseattle 13y agoInteresting. Externally, it sounds like lots of code being generated that's somewhat a mirror of each other. Were there cases where a bugfix was needed across code that had already been generated? How was that handled?
- mcv 13y agoI believe there was some typo or deviation of the regular format in the functional design once or twice, which I fixed by hand. There was also a clear error in the logic specified in the design, which I was required to implement anyway. I pointed it out, explained them how it should be, and it took a remarkable amount of bureaucracy and responsibility dodging to get it fixed, but it was no problem for my work. Generally after generating the big amount of code, I still checked everything manually and added the needed boilerplate. It's just the initial generation of hundreds of if-then blocks to build texts that I automated.