For this sort of thing I prefer to build up a string, and print the whole string at the end. This allows me to keep related things together: it scares me, for example, that there is so much distance between the point that you emit the public class $class\{ and the point you emit the closing '}'. Instead I might wrap it as something like:
.. and I'd probably end up putting it in a little function.sprintf <<CLASS, $class, $classdef; public class %s { %s } CLASS
I do this because I find it more robust against future changes. Programs like this tend to get extended over time in a manner rather like the expansion of the universe - any two lines of code will tend to get further apart as time passes, and by the time the code emitting the '{' and the '}' are in separate source files you've created a big maintenance headache.
Another benefit of building up a string to be written at the end is that it doesn't create a (broken) output file if you break out of the program during the 'enter properties' loop.
Hugo
In reply to Re: A place for code reviews
by hv
in thread A place for code reviews
by johnnywang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |