图中两个节点之间是用“关键字”联系起来的,但是数据库还没有设计好。“设计实现该技术点时,要抛开数据库,留接口。”这里的关系怎样用“接口”进行定义。

解决方案 »

  1.   

    interface person{
      string name;
      string country;
      .......
      string[] void getRelationShip();
      ........
    }
      

  2.   

    interface IPerson{
      string name;
      string country;
      .......
      ArrayList getRelationShip();
      ........
    }publi class ChenHu: IPerson{
      string name;
      string country;
      ArrayList friends=new ArrayList();
     
        .......
      ArrayList getRelationShip()
      {
         return friends;  
      }
      
      void setRelationShip(IPerson p)
      {
        this.friends.add(p)  
      }
      ........}
      

  3.   

    首先看图中的关键字球,有两种类型,一种是人,一种是国家,那么可以定义一个统一的关键字接口IKeyBehavior,然后让人和国家都继承这个统一的接口,然后再看,这些关键字之间都是有着各种各样的关系,那么就必然有个关系接口,定义为IKeyRelation,然后在IKeyBehavior接口中有个指向IKeyRelation的引用集合List<IKeyRelation>,最后在IKeyRelation中有个指向IKeyBehavior引用的关联对象(意思是指有关系的东西)。
    public interface IKeyBehavior
    {
        string name;      //关键字名称
        List<IKeyRelation> relats;   //有关系的关键字集合
    }
    public interface IKeyRelation
    {
        string name;           //关系名称
        IKeyBehavior object;   //有关系的关键字
    }
      

  4.   

    定义JS接口操作Cookie完成客户端交互,然后使用WCF完成服务器交互。