Topic awaiting preservation: Java - Writing a command line interface (Page 1 of 1) |
|
---|---|
Paranoid (IV) Inmate From: Back in West Texas... How disappointing |
posted 09-28-2004 02:01
In what little spare time I have I'm working on a swing app (fairly simple drawing program), and I'd like there to be a command line interface to it. I've got the basic layout of something that could work so far (100+ if-else-if statements, nested 5 deep in spots), but there's got to be a better/faster/more organized/more efficient/etc way to do it. |
Paranoid (IV) Inmate From: [s]underwater[/s] under-snow in Juneau |
posted 09-28-2004 02:51
How about using switch statements? Much cleaner..... |
Paranoid (IV) Inmate From: Back in West Texas... How disappointing |
posted 09-28-2004 03:27
That'd be a step in the right direction, but it still seems to me that there should be a better way to handle it... |
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 09-28-2004 05:50
I would think that the if/else method might be a little difficult, and a whole lot of writting, and very slow O(n) processing. code: public static void main(String[] args){
|
Paranoid (IV) Inmate From: Back in West Texas... How disappointing |
posted 09-28-2004 21:09
quote: which is why I ended up with what I did, although in the long run, hundreds of if-else-if's makes your brain hurt after staring at it long enough. quote: What if I were using 1.5? I'm using 1.4.2, so it's not an issue, but what changed in 1.5? I've heard various people mention that there were some big changes, but I haven't taken the time to check it out any more than that. |
Paranoid (IV) Inmate From: Madison, Indiana, USA |
posted 09-28-2004 21:33
WarMage: What you have described is a Recursive Descent parser. I was just going to recommend that a Recursive Descent parser might work better than if-else if, although I like if-else if for small languages (50 key words of less). |
Paranoid (IV) Inmate From: Back in West Texas... How disappointing |
posted 09-29-2004 03:35
So far, I'm up to about 40 keywords I think. It started out much smaller (about 10-15 keywords), but it grew shortly after I got it working :: |
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 09-29-2004 04:45
The change in 1.5 that I am talking about is that sun has again done the smart thing and taken a bit of C. |