A script class that generates a string in chunk-format, which can be filed in to add methods which get and set bits in a flag instance variable.
Rather than compiling any code, my typical approach is to generate a chunk string which I can then file-in. I find I can avoid much of the error checking needed when compiling code while still saving myself most of the typing and time.
The Dolphin base image contains many examples of using a single instance variable to implement multiple testing methods via the use of classVariable masks. Example base classes are; AttributeDescriptor, CommandDescription and CompiledCode.
My problem is that I get lazy; a class might start out with one or two testing methods/instance variables, but if that grows to three or four, I start thinking about converting it to using a single flag instance variable with masks.
The attached class generates the required methods, and means I can avoid all that typing.
I could write something that compiles the code, I could also (attempt to) write a refactoring class, but I find this saves enough time to be useful.
The download is a class fileout as this class lives in my StartUp package. SWUFlagWriter.zip (3kb).
Copyright Steve Waring 2002.