宽接口和窄接口

宽接口:
IInterFace1=interface
  //方法列表
end;

窄接口:对象接口,接口声明和类相似,但不能直接实例化,也不能自己实现它们的方法,而是由支持接口的类来提供实现。
type
  TStrategy=class(TObject)//抽象策略
  public
    procedure Hello;virtual;abstract;
  end;

  TContext=class(Tobject)//上下文
  private
    FStrategy:TStrategy;//引用已有的对象(窄接口)
    Procedure SetStrategy(Value:TStrategy);
  public
    procedure ContextInterface;//向已有的对象委派责任
    property Strategy:TStrategy read FStrategy write SetStrategy;
  end;  
posted @ 2008-03-14 12:59  delphi中间件  阅读(542)  评论(0编辑  收藏  举报