How to manage (or exclude) parallel class hierarchies?

I am developing a simple form creation mechanism in which users can create new forms using various types of template fields (Date, Text, DropDown)

I decided to model the domain object (form field) regardless of the objects that will be used to visualize these fields in the user interface.

Here is the interface that defines the contract for the domain and some of its specializations:

namespace Acme.Core.Domain{
    public interface IFormField
            {
                bool Visible { get; set; }
                string Key { get; set; }
                event EventHandler<FieldVisibilityChangedEventArgs> VisibilityChanged;
                FieldType Type{get;}
                void Validate(IEnumerable<ValidationError> errors);
                int DataId {get;set;}
            }

    public interface IDropDownField:IFormField{

                IDictionary<string, string> Items { get; set; }
                KeyValuePair<string, string> SelectedValue { get; set; }

        }
     public interface IDateField:IFormField{

                DateTime? SelectedDate{get;set}

        }
}

For the user interface side, I built a parallel type hierarchy. This saves the domain object that is associated with business rules around data validation, separate from user interface problems, namely how to visualize this field (MVC HtmlHelper vs WebForm WebControl):

namespace Acme.UI{

        public interface IControl 
        {
                //parallel to IFormField
                bool Visible { get; set; }
                string ID { get; set; }     
        }

        public interface IDropListControl:IControl 
        {
                //parallel to IDropDownField

        }
        public interface IDatePickerControl: IControl 
        {
                //parallel to IDateField

        }

       public interface IControlFactory {

             IControl CreateControl(IFormField field);
       }
    }

, . , , , . , ?

EDIT: UI - (Core.csproj). , . , , .

    // create concrete instances of IControl based on the the domain object passed in 
   public interface IControlFactory {

                 IControl CreateControl(IFormField field);
       }
       // scrape values form the UI controls and apply them to the appropriate domain object
       public interface IFormFieldDataBinder{

                void Bind(IFormField field, IControl control);
       }
+5
1

, , , --. , , , , dropdownlist, , , , ?

, IDropdownListControl "Render"?

IFormField IControl , , , ?

, IDropDownField MVC, , . , ( , ).

IDropListControls IDropDownField ? ( IDropDownField IDropListControl).

. ?

+1

All Articles