2011-07-06 3 views
1

Flex RIA 애플리케이션 용 Cairngorm 마이크로 아키텍처에서 클래스 관계를 모델링하려고합니다. 나는 약간의 혼란을 가지고있다.UML의 상속 및 종속성 모델링

예를 들어 FrontController와 Controller라는 두 클래스가 있습니다. 컨트롤러는 FrontController를 확장합니다. 반대쪽에는 ICommand 인터페이스와 ICommand를 구현하는 SaveEmployeeCommand가 있습니다.

을 FrontController는

public function init():void 
{ 
    // SaveEmployeeEvent extends CairngormEvent 
    // SaveEmployeeCommand implements ICommand interface 
    //### THIS IS DEPENDENCY ON SaveEmployeeEvent AND SaveEmployeeCommand ### 
    addCommand(SaveEmployeeEvent.SAVE, SaveEmployeeCommand); 
} 

그래서, 그냥이 명령에 종속 생각해 보자 ...

public function addCommand(commandName : String, commandRef : Class, useWeakReference : Boolean = true) : void 
    { 
    if(commands[ commandName ] != null) 
     throw new CairngormError(CairngormMessageCodes.COMMAND_ALREADY_REGISTERED, commandName); 

    commands[ commandName ] = commandRef; 
    CairngormEventDispatcher.getInstance().addEventListener(commandName, executeCommand, false, 0, useWeakReference); 
    } 

/** 
    * Executes the command 
    */ 
    protected function executeCommand(event : CairngormEvent) : void 
    { 
    var commandToInitialise : Class = getCommand(event.type); 
    //#### THIS IS DEPENDENCY ON ICommand INTERFACE #### 
    var commandToExecute : ICommand = new commandToInitialise(); 

    commandToExecute.execute(event); 
    } 

컨트롤러는 다음과 같이이다 생성자 느릅 나무의 init 메소드를 가지고 ...이 두 가지 방법이있다. 코드를 살펴보면 FrontController가 ICommand에 종속되어 있고 Controller에 SaveEmployeeCommand에 대한 종속성이 있음을 알 수 있습니다. UML 클래스 다이어그램에 'Controllers-> Commands'의존성을 모두 표시해야합니까? (첫 번째 종속성은 FrontController-> ICommand이고, 두 번째는 Controller-> SaveEmployeeCommand입니다.)
혼란은 상속 부분입니다. FrontController와 Controller 사이에 상속 관계를 설정하면 컨트롤러가 FrontController이기 때문에 ICommand에 대한 종속성도가집니다 (종속성은 addCommand 메서드로 상속 됨). 이 상황을 어떻게 모델링해야합니까? 나는 가능한 해결책의 몇 가지 예를 든다 ... 어떤 제안? 다이어그램에서

Dependencies model

답변

0

관계는 고정 관념을 제외하고, 올바른 본다. 나는 FrontController와 ICommand 사이의 의존성을 <<Instantiate>>으로 바꿀 것이다.