美文网首页
10 探索类与类之间的关系(未完待续)

10 探索类与类之间的关系(未完待续)

作者: Closears | 来源:发表于2017-11-08 22:43 被阅读5次
  1. Object Composition (可细分为CompositionAggregation两部分),
    "it allows us to create complex classes by combining simpler, more easily manageable parts."
    1.1 Composition与Aggregation的共同点
    The part (member) is part of the object (class) . - part-whole relationship
    The part (member) does not know about the existence of the object (class).- unidirectional relationship
    1.2 Composition与Aggregation的区别

Composition:

  1. Parts can belong to only one object at a time.
  1. The whole object is responsible for the existence and lifespan of the parts.
  1. It models "part-of" relationships.
  1. In a composition, we typically add our parts to the composition using normal member variables (or pointers where the allocation and deallocation process is handled by the composition class).

Aggregation:

  1. Parts can belong to more than one object at a time.
  1. The whole object is not responsible for the existence and lifespan of the parts.
  1. It models "has-a" relationships.
  1. In an aggregation, we also add parts as member variables. However, these member variables are typically either references or pointers that are used to point at objects that have been created outside the scope of the class.
  1. TBD

相关文章

  • 10 探索类与类之间的关系(未完待续)

    Object Composition (可细分为Composition和Aggregation两部分),"it a...

  • 类图,对象图,时序图

    1.类图 1.类与类之间的关系: 在绘制类图前,先熟悉类与类之间的关系。面向对象语言中类与类之间关系共计六种,分别...

  • 使用StarUml绘图概括

    1.类与类之间的关系: 在绘制类图前,先熟悉类与类之间的关系。面向对象语言中类与类之间关系共计六种,分别是继承、实...

  • 类与类之间的关系

    类是一系列对象的集合(类是存放对象的地方) 在类之间常见的关系有: 1.依赖 (“use-a”) 2.聚合 4....

  • 类与类之间的关系

    一、继承关系 继承指的是一个类(称为子类、子接口)继承另外的一个类(称为父类、父接口)的功能,并可以增加它自己的新...

  • 技术问 - 类与类,接口与接口,类与接口各自之间的关系

    类与类,接口与接口,类与接口各自之间的关系:

  • 一对多的双向

    一对多指的是类与集合之间的关系多对一指的是类与类之间的关系 one-to-many:一对多指的是类与集合之间的关系...

  • 03.接口和类之间的各种关系

    接口和类的关系 A:类与类之间:继承关系,一个类只能直接继承一个父类,但是支持多重继承 B:类与接口之间:只有实现...

  • 类图与类之间关系

    UML类图画法及其之间的几种关系 最近做重构项目,需要画一下类图,发现类图的画法及其之间的几种关系已经淡忘了很多,...

  • UML类图

    UML类图帮助我们标明类之间的关系,而在学习UML类图之前,得先理清类与类之间的关系。类的关系有泛化(Genera...

网友评论

      本文标题:10 探索类与类之间的关系(未完待续)

      本文链接:https://www.haomeiwen.com/subject/ivcumxtx.html