Re: How to redesign big switch case?
From: Victor Bazarov (v.Abazarov_at_comAcast.net)
Date: 03/22/04
- Next message: JR_JR: "automake / autoconf include libs"
- Previous message: Siemel Naran: "How to redesign big switch case?"
- In reply to: Siemel Naran: "How to redesign big switch case?"
- Next in thread: Alex Vinokur: "Re: How to redesign big switch case?"
- Reply: Alex Vinokur: "Re: How to redesign big switch case?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 22 Mar 2004 05:21:35 GMT
"Siemel Naran" <SiemelNaran@REMOVE.att.net> wrote...
> 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.
So, why not have a table (std::map) of pairs {char/[member]function ptr}?
V
- Next message: JR_JR: "automake / autoconf include libs"
- Previous message: Siemel Naran: "How to redesign big switch case?"
- In reply to: Siemel Naran: "How to redesign big switch case?"
- Next in thread: Alex Vinokur: "Re: How to redesign big switch case?"
- Reply: Alex Vinokur: "Re: How to redesign big switch case?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|