How to redesign big switch case?
From: Siemel Naran (SiemelNaran_at_REMOVE.att.net)
Date: 03/22/04
- Next message: Victor Bazarov: "Re: How to redesign big switch case?"
- Previous message: Siemel Naran: "Re: Simple regex / split example?"
- Next in thread: Victor Bazarov: "Re: How to redesign big switch case?"
- Reply: Victor Bazarov: "Re: How to redesign big switch case?"
- Reply: Jeff Schwab: "Re: How to redesign big switch case?"
- Reply: Razvan Popovici: "Re: How to redesign big switch case?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 22 Mar 2004 04:50:46 GMT
How to redesign big switch case?
I wrote an editor that reads chars, and does a switch (char) to process the
character. For example, if char is HOME then go to the beginning of the
line, and if char is CTRL-RIGHT then go to the start of the next word. As I
added more cases and support for reverse incremental history mode, the code
grew longer and longer. It is now 562 lines, or 58% of the entire file.
This seems a bit clumsy. Fortunately the code does not have any goto
statements and seems pretty structured and clear to me, so it's not exactly
sphaghetti code. Is it worthwhile to change the code? If yes, then how?
Finally, it would be nice to allow users to derive their own editor class
from my one and add support for more special keys.
Thanks.
- Next message: Victor Bazarov: "Re: How to redesign big switch case?"
- Previous message: Siemel Naran: "Re: Simple regex / split example?"
- Next in thread: Victor Bazarov: "Re: How to redesign big switch case?"
- Reply: Victor Bazarov: "Re: How to redesign big switch case?"
- Reply: Jeff Schwab: "Re: How to redesign big switch case?"
- Reply: Razvan Popovici: "Re: How to redesign big switch case?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|