`

依赖(use a),关联(has a),聚合[聚集],组合[合成],泛化(is a)

阅读更多
关联、组合、聚合、依赖关系比较
http://www.blogjava.net/tinysun/archive/2009/02/21/255957.html
范化、依赖、关联、聚合关系的一些理解
http://www.cnblogs.com/riordan/archive/2007/06/09/777813.html
区分java中的依赖、关联、聚集关系
http://kisssk.iteye.com/blog/467198
聚集
http://baike.baidu.com/view/351119.htm


-----------------------------------------------------
总结:
1.依赖(use a)
A类中使用B类去完成相关任务,A类中无有B类这属性,可能是在方法中用到B类.

2.关联(has a)
关联分双向关联和单向关联,双向关联是A,B类分别持有对方的引用(有是对方的属性).
单向关联是一方持另一方的引用.

3.聚合[聚集]
聚合是更强一点的关联,是一种弱的“拥有”关系。体现的是A对象可以包含B对象,但B对象不是A对象的组成部分.
例如,汽车是由轮子聚合而成,汽车报废时,轮子可以单独存在.聚合与组合的不同在于被拥有者的生命周期.

4.组合[合成]
是关联关系的一种,是比聚合关系强的关系。它要求普通的聚合关系中代表整体的对象负责代表部分的对象的生命周期。Composition(组合关系)是一种强的“拥有”关系,体现了严格的部分和整体的关系,部分和整体的生命周期一致。如果A由B组成,表现为A包含有B的全局对象,并且B对象在A创建的时刻创建。
例如,人与手脚.

5.泛化(is a)

构造的详细顺序如下:

类构造 (只做一次的,不论你new了多少个对象)

1.父类的static 属性(field)
2.父类的static块(block)
3.子类的static field
4.子类的static block

实例构造 (new一次做一次)

1.实例父类的field (非static)
2.实例父类的初始化block (非static,是用{}括起来的那些)
3.实例父类的默认构造器 (默认构造器是类名()这个)
4.实例子类(这个类)的field
5.实例子类(这个类)的初始化block
6.实例子类(这个类)的默认构造器 /no 应该是new的那一个构造器,见Parent e = new Parent(10,12);

http://ap0406708.iteye.com/admin/blogs/358924
分享到:
评论

相关推荐

    Python 3.7 is a programming language

    IPython is a powerful interactive shell that features easy editing and recording of a work session, and supports visualizations and parallel computing. The Software Carpentry Course teaches basic ...

    java中类与类之间的关系

    这些关系包括泛化、依赖、关联和聚合等。了解这些关系对于设计和实现软件系统非常重要。 一、泛化关系 泛化关系是类与类之间的继承关系,接口与接口之间的继承关系,或类对接口的实现关系。这种关系是从子类指向...

    A First Course in Mathematical Analysis.pdf

    A First Course in Mathematical Analysis Mathematical Analysis (often called Advanced Calculus) is ... It is suitable for self study or use in parallel with a standard university course on the subject.

    Pro Docker: Learn how to use Containers as a Service for development and

    packaging and running portable distributed applications, Deepak Vorhadiscusses how to build, ship and run applications on any platform such as a PC, the cloud, data center or a virtual machine....

    A Little Java, A Few Patterns

    Java is a new object-oriented programming language that was developed by Sun Microsystems for programming the Internet and intelligent appliances. In a very short time it has become one of the most ...

    Delphi in a Nutshell

    With a new name and a new focus on CORBA, database drivers, and Microsoft Back Office applications, Inprise/Borland Delphi is enjoying a resurgence, with a growing user base of programmers who use ...

    This module is for use in VB6 only with DirectX 7.0a or bett

    This module is for use in VB6 only with DirectX 7.0a or better installed to use Direct Sound. Works with most sound cards. ReadMe file is included and comments have been added to make using the ...

    UML类与类的关系.doc

    UML中的类与类之间的关系是理解和设计复杂系统的关键,包括泛化、关联、依赖、聚合和组合等。 ### 泛化(Generalization) 泛化关系表示了类之间的继承关系,它体现了“is-a”(是一种)的概念,即子类是父类的一种...

    Your page is blocked due to a security的解决方案

    关于Your page is blocked due to a security的解决方案

    总结之UML(新闻发布系统版).pdf

    它用于定义系统的静态结构,包括类的属性、操作、接口定义,以及类与类之间的关联、依赖、聚合、组合和泛化关系。类图还可以用于逻辑数据库建模,描述数据表之间的关系。 3. **对象图(Object Diagram)**:对象图是...

    apng2gif.sf.net.rar

    gif2apng is a simple program that converts animations from GIF to APNG format. It disproves the common misconception that Animated PNG files are always too big, as it actually creates APNG files ...

    LAN8720A数据手册

    The LAN8720A/LAN8720Ai is a low-power 10BASE-T/100BASE-TX physical layer (PHY) transceiver with variable I/O voltage that is compliant with the IEEE 802.3-2005 standards. The LAN8720A/LAN8720Ai ...

    S7A驱动720版本

    in the demo mode, or the value 1, when the driver has found a valid key, and therefore is licenced. This function is also available via the OPC server interface. The same item-ID address format has...

    A Practical Guide to Designing for the Web.pdf

    Modern web design is a discipline that spans a huge range of skills. Often though, the wider the span, the thinner the knowledge. That needs to change. Graphic design has such a rich, and useful ...

    C# 7.0 in A Nutshell

    Organized around concepts and use cases, this updated edition provides intermediate and advanced programmers with a concise map of C# and .NET knowledge. Dive in and discover why this Nutshell guide ...

    NET Windows Forms in a Nutshell

    This book is a desktop reference and tutorial for Windows Forms, the new API for writing GUI applications for Windows. Windows Forms is a part of the .NET Framework, the first version of which shipped...

    This is a small project showing how to use the Sleep API cal

    This is a small project showing how to use the Sleep API call from within your program to pause for a set period of time. Its much better than looping round as it uses very little CPU time

Global site tag (gtag.js) - Google Analytics