User control design question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • indyanguy
    New Member
    • Jan 2008
    • 3

    #1

    User control design question

    Hi all,

    I have a dashboard page that hosts several sections. Each section can have different modes (Ex: preview mode, edit mode etc) and one of the differences between the modes are how they are rendered.
    I plan to implement these sections as user controls. I will expose a property in the UC that defines the mode. I will need need some way of having the user control behave in a different way and render layout differently.

    Question:

    1. From the architecture perspective, would it be more efficient if I simply have different user controls for different modes?

    2. If I go with a single UC, I can have panels that I hide/show based on the mode. I can then define a base class for each UC and create subclasses (that represents different modes) that derive from this class. This would be similar to a strategy design pattern.


    Is there a better design? Thoughts?
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Personally I like the idea of a single control for each type, and have that control smart enough to handle the mode its in.

    That way you avoid:
    - Speedometer-Basic
    - Speedometer-Intermediate
    - Speedometer-Advanced

    and so on.

    I would think it much cleaner to just have a single "Speedomete r" control that takes a parameter of "mode" on creation.

    If you also react to a mode change then the same control already in place can change from "basic" mode to "advanced" mode when a different user logs in.

    You could also have a mix of modes depending on the user. Maybe Bob is allowed to see the advanced mode of the Speedometer control, but only the basic mode of the Preferences control because he can be an operator but not allowed to change the overall appearance. Etc. This is how I set up most of my apps. A user can have a mix of features checked to 'on'. They are allowed to make changes, but not allowed to close the application... They can change color schemes, but can't remove elements from the display. And so on.

    Comment

    Working...