开发者

Inheritance and dependencies modeling in UML

开发者 https://www.devze.com 2023-03-18 01:43 出处:网络
I\'m trying to model class relationships in Cairngorm micro-architecture for Flex RIA applications. I have a little confusion.

I'm trying to model class relationships in Cairngorm micro-architecture for Flex RIA applications. I have a little confusion.

For example, I have two classes FrontController and Controller. Controller extends FrontController. On the other side, I have ICommand interface and SaveEmployeeCommand which implements ICommand.

FrontController has this two methods...

  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 );
  }

Controller has init method in constructor wich is like this...

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

So, let's consider just dependencies on commands. If we look at code we will see that FrontController has dependency on ICommand and that Controller has some kind of dependency on SaveEmployeeCommand.Should I show both 'Controllers->Commands' dependencies on UML class diagram?(First dependency is FrontController->ICommand, second is Controller->SaveEmployeeCommand)

My confusion is about inheritance part. If I put inheritance relationship between FrontController and Controller, it means that Controller is also FrontController, so he has dependency on ICommand too(dependency is inherited with addCommand method). How should I model this situation? I put some example of possible solution... Any suggests?

Inheritance and dependencies modeling in UML


The relations in your diagram look correct, except for the stereotype. I would change dependency between FrontController and ICommand to <<Instantiate>>.

0

精彩评论

暂无评论...
验证码 换一张
取 消