EditModel을 명령 메시지에 매핑하는 방법은 무엇입니까?
-
19-09-2019 - |
문제
Los Techies의 지미 보가드 그는 자신의 EditModel을 명령 메시지에 매핑한다고 말합니다. EditModel을 DomainModel에 매핑하는 대신.누구든지 이것을 더 자세히 설명할 수 있습니까?
해결책
버전이 아닐까 싶습니다. 명령 패턴 제공된 메시지를 기반으로 관련 도메인 개체에 필요한 조작을 수행합니다.예를 들어다음과 같은 것
public PromoteEmployeeCommand : ICommand {
private readonly PromotionMessage _message;
private readonly IEmployeeRepository _repository;
public PromoteEmployeeCommand(PromotionMessage message,
IEmployeeRepository repository) {
_message = message;
_repository = repository;
}
public void Execute() {
/* Get the employee, give them a rise etc... */
}
}
편집 모델의 매핑은 필요에 따라 호출될 수 있는 여러 명령 메시지로 해석됩니다(예:직원에게 월급을 주고, 관리자에게 알리고, 급여에 대한 메모를 추가하는 등).
이 접근 방식의 장점은 편집 모델에 의해 노출된 표현 문제로부터 도메인 모델을 격리할 수 있다는 것입니다.
제휴하지 않습니다 StackOverflow