`
blues1021
  • 浏览: 135649 次
  • 性别: Icon_minigender_1
  • 来自: 南宁
社区版块
存档分类
最新评论

类图use-a,has-a,contain-a(composition),implements,extends区别

 
阅读更多

一、横向关系:
1.depedency依赖,use-a
是类之间的一种很弱的联系
, use-a ,send-a,parameter-a 关系,常用是将一个类对象作为一个类里面方法的参数。是偶然的,临时的, 对象间是并列关系 调用了一个对象,以利用它的成员。
2.association关联,use-a
他体现的是两个类、或者类与接口之间语义级别的一种强依赖关系,比如我和我的朋友;这种关系比依赖更强、;是固定的、长期的、对象间是并列的、可单向或双向的, 1被关联类对象以类属性的形式出现在关联类中,2也可能是关联 类A引用了一个类型为被关联类B的全局变量。一般不是依赖、聚合和组合的非整体与局部(特别是对类的全局变量引用 )就说关联关系。
属于关联下的聚合和组合关系(整体与局部关系):
3.aggregation聚合,has-a异步 ,学校与学院,用到了类a,因为要用类a的成员。弱的整体与局部关系,因为有a对象,但是a对象也可以被其他类拥有。他们之间不是生死与共的生命周期,然后是局部对象作为整体类的属性, 局部的对象是可以在外面先创建的,可以被多个整体类调用,毁灭时不一定毁灭它。 A relationship B用实线空菱形箭头表示。
整体类属性,创建时间,其它类调用,毁灭时间。
4.composition组合,contain-a同步 ,窗口与菜单按钮,包含a,强的整体与局部的关系,拥有了a,且有且仅有它拥有a对象,是生死与共的生命周期,将局部的对象作为整体类的属性,创建时创建,只有被当前类使用,特别是毁灭时毁灭。 A relationship B用实线实心菱形表示。
整体类属性,创建时间,其它类调用,毁灭时间。
在C++语言中,从实现的角度讲,聚合可以表示为:
class A {...}
 class B { A* a; .....}  //* a只是引用指针,也就是A对象的创建不在这里。

即类B包含类A的指针;

而组合可表示为:

class A{...}
 class B{ A a; ...}

即类B包含类A的对象。
其关系强弱为dependency<association<aggregation<composition
二、纵向关系:
5.implements, 实现接口 虚线实体大箭头表示.
6.extends IS-a 就是继承关系了,当添加了新的方法就是is-like-a,应该首先考虑组合而不是继承,因为组合可以毫不影响引用类,且可以动态的修改新类的成员(来自java编程思想)。泛化: 继承实现方法多态的形式,实线大箭头表示。

分享到:
评论

相关推荐

    A&amp;H IDR-8音频处理器说明

    has a hardware limiter before the A-D converter so that the contractor can have confidence in the signal integrity, even if input levels exceed what was expected. Signal Processing The iDR-4 & iDR-8 ...

    SSD7 选择题。Multiple-Choice

    When mapping from an ER model to a relational model, a strong entity is mapped into a (a) table (b) row (c) column (d) key Correct answer is (a) 10. Which of the following is true about ...

    信息安全_数据安全_dev-r1-2-devsecops-using-contain.pdf

    信息安全_数据安全_dev-r1-2-devsecops-using-contain 可信计算 业务安全 水坑攻击 安全防御 数字取证

    Production Testing of RF and System-on-a-Chip Devices for Wireless Communications((Artech.House.Publishers.Apr.2004)

    System-on-a-Chip Devices for Wireless Communications Keith B. Schaub Joe Kelly ========================== It came to our attention that there were not any books available that enlightened the engineer...

    ptpv2d-rc1.tar

    IEEE 1588 may contain patented technology, the use of which is not under the control of the authors of PTPd. Users of IEEE 1588 may need to obtain a license for the patented technology in the ...

    Unlocker(解锁顽固文件)

    contain bugs, so use of this tool is at your own risk. We take no responsibility for any damage that may unintentionally be caused through its use. You may not distribute Unlocker in any form without...

    BURNINTEST--硬件检测工具

    - A hang on startup has been corrected. A 2 minute timeout has been added to the collection of system information. - Video playback, Hard disk and CD/DVD test 'no operations' error reporting ...

    Zim - A Desktop Wiki

    Zim is a graphical text editor used to maintain a collection of wiki pages. Each page can contain links to other pages, simple formatting and images. Pages are stored in a folder structure, like in an...

    Fault insertion testing of a novel CPLD-based fail-safe system.pdf

    The described method exploits the fact, that the system contains two channels, where both channels contain a CPLD. During a test one CPLD is configured using a modified programming file. This file ...

    HiddenBits.rar_contain-ppt_doc

    Hidden Bits : A Survey of Techniques for Digital Watermarkingm contain matlab code., work picz overview (.doc ) file (.ppt) file

    Django 2.0.6 开发文档

    Django has a lot of documentation. A high-level overview of how it’s organized will help you know where to look for certain things: Tutorials take you by the hand through a series of steps to create...

    Python Django官方学习资料

    Django has a lot of documentation. A high-level overview of how it’s organized will help you know where to look for certain things: • Tutorials take you by the hand through a series of steps to ...

    2009 达内Unix学习笔记

    id -a root 显示用户所在组的所有组名(如root用户,是所有组的组员) df 查看文件系统,查看数据区 用法 df [-F FSType] [-abeghklntVvZ] [-o FSType 特定选项] [目录 | 块设备 | 资源] df -k 以kbytes显示文件...

    Sakemail

    Also Roger has made the IPAddress property obsolete (do not use it, use Host instead), SakEmail will resolve the host properly no matter if it is a host name or a IP address. So in the next version I...

    css-has-pseudo:相对于其他元素的样式元素

    a : has ( &gt; img) { /* style links that contain an image */}h1 : has( + p) { /* style level 1 headings that are followed by a paragraph */}section : not ( : has ( h1 , h2 , h3 , h4 , h5 , h6 )) { /* ...

    Cambridge University-A Guide to MATLAB 2006.pdf

    Here is a short, focused introduction to MATLAB, a comprehensive software system for mathematics and technical computing that should be useful to both beginning and experienced users. It contains ...

    jQuery完全实例.rar

    Allows you to bind a function to be executed when the DOM document has finished loading. This function behaves just like $(document).ready(), in that it should be used to wrap other $() operations on ...

    Oxford_university_press_-_a_practical_english_grammar

    A clear, comprehensive reference grammar. 'The strength of the book is that examples from classroom research are used to demonstrate how meta-language about grammar and meaning can be included, rather...

    JSP Simple Examples

    A form can contain checkboxes, textfields, radio- buttons and many more. Forms are used to pass user- data to a specified URL which is specified in the action attribute of the form tag. Interface ...

    squashfs2.2-r2.tar.gz

    SQUASHFS 2.2 - A squashed read-only filesystem for Linux Copyright 2005 Phillip Lougher (phillip@lougher.demon.co.uk) Released under the GPL licence (version 2 or later). Welcome to Squashfs ...

Global site tag (gtag.js) - Google Analytics