Take the 2-minute tour ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I need criticism/suggestions on a suitable way of controlling many states of display in a GUI like method, "GUIMethod", below.

/*
 *InterfaceState.cs
 */
public struct UIController {
    public static InterfaceState interfaceState;
}
public enum InterfaceState {
    ENUMS,
    SEEM,
    EASY,
    TO,
    WRITE,
    TODAY
}

/*
 *EnumsAndWrite.cs
 */
public class EnumsAndWrite {
     public void GUIMethod() {
         switch (UIController.interfaceState) {
             case InterfaceState.ENUMS:
                 case_ENUMS_func_1();
                 case_ENUMS_func_2();
                 case_ENUMS_func_3();
             break;
             case InterfaceState.WRITE:
                 case_WRITE_func_1();
                 case_WRITE_func_2();
                 case_WRITE_func_3();
             break;
         }
     }
    //Methods defined
}
/*
 *SeemEasy.cs
 *Similarly written; handles SEEM and EASY
 */
public class SeemEasy {
    public void GUIMethod() {
         switch (UIController.interfaceState) {
             case InterfaceState.SEEM:
             break;
             case InterfaceState.EASY:
             break;
         }
    }
}
/*
 *ToToday.cs
 *Similarly written; handles TO and TODAY
 */

I use a struct because I just need the static reference to the InterfaceState type. Whenever I need to change the state of InterfaceState I simply assign it to the respective needed item in InterfaceState. It seems easy and very maintainable.

share

migration rejected from stackoverflow.com Jan 13 at 6:50

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as off-topic by RubberDuck, janos, Morwenn, Simon André Forsberg, Heslacher Jan 13 at 6:50

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

    
I'm not sure I can really comment on this solution here. The always annoying answer of "it depends" applies here. Could you please go one step back and instead of showing the code, lay out your requirements and what the GUI should accomplish? –  Ameen Jan 16 '13 at 22:10
    
@avidprogrammer, I find your example too abstract to efficiently answer the question. I would want to know your specific application at hand; that is just how my brain works. –  Leonid Jan 19 '13 at 18:58

Browse other questions tagged or ask your own question.