Sophisticated user interface & # 8594; MVC pattern

I read a lot about MVC / MVP templates .... I have a simple question ... If you have a view with many controls ... let's say 10 text boxes and 10 flags .... etc. etc. Do I intend to specify properties and events for each of them in my IView interface? ....

0
source share
1 answer

Definitely not so. Your IView interface will define a set of contracts / methods (including properties) that can be accessed at your business level. It is completely wrong to expose your control in an interface as follows:


public interface IView
{
  TextBox UserNameTextBox{get;set;}
}

, . . , . .


public interface IView
{
 public void SetUserName(string Text);
}

winform, -.

, (). , Employee . Employee , Employee.
BL n .


public class Employee
{ 
  //first name
  //last name
  //is manager
  //is teamleader
  //address
}

public interface IEmployeeView
{ 
  void SetEmployee(Employee employee);
}


public partial class EmployeeForm:WinForm,IEmployeeView
{
  public void SetEmployee(Employee employee)
  {
    ENameTextBox.Text = employee.FirstName+" "+employee.LastName;
  } 

}

+2

Source: https://habr.com/ru/post/1739088/


All Articles