Enums.
Sun had done a surprisingly awesome job with them.
In fact, there are a lot of nice ways you can implement Java enums to create new design methodologies within your programs.
In fact, I prefer Java enum implementation over all the other languages implementation.
Enums with intelligence.
I’ve just been reading about them now in depth because how I’ve been using enums is the same as in any other language.
However, I had a great idea. Call it a brain fart.
I’ve been reading Sun’s explanations and when I noticed this in particular:
public enum Operation {
PLUS, MINUS, TIMES, DIVIDE;
// Do arithmetic op represented by this constant
double eval(double x, double y){
switch(this) {
case PLUS: return x + y;
case MINUS: return x - y;
case TIMES: return x * y;
case DIVIDE: return x / y;
}
throw new AssertionError("Unknown op: " + this);
}
}
I came to the conclusion that if you were to right a scripting language and pass it into Java, you can have values passed into Enums to automate the work real nice and neat.
So what do you guys think?