posted 13 years ago
I do not know enough about what you want to be complete, but I've coded two things that illustrate what I'm talking about in the code below:
The idea is to put the logic about doing the actual work the user has requested in methods (and perhaps classes) that are separate from ones that do anything with the user interface. So if a routine figures out that a "white" option has been chosen (a UI thing), it invokes a method that does the work involved; the invoked method does not know or care that any particular menu item was chosen, just that it is supposed to go ahead and do a specific job. And when an option is chosen that is the equivalent of choosing multiple menu options, the resulting UI code can invoke all the work-doing methods in turn, so all the work gets done without copying that work code into a UI routine.
ANY time you find that copy-and-paste is tempting, look for a way to reorganize your code so that it isn't necessary. If the problem you are trying to solve has copies, it might just reflect the nature of the problem, but that is quite rare, actually.
rc