类图和对象图

类图与对象图的基本概念

在UML中,系统静态结构的描述主要是通过类图和对象图来实现的。类图从抽象的角度描述系统的静态结构,特别是模型中存在的类、类的内部结构以及他们与其他类之间的相互关系,而对象图是系统静态结构的一个快照,是类的实例化表示。

含义

        类图显示了系统的静态结构,而系统的静态结构构成了系统的概念基础。系统中的各种概念都是现实应用中有意义的概念,这些概念包括真实世界中的概念、抽象的概念、实现方面的概念和计算机领域的概念。类图就是用于对系统中的各种概念进行建模,并描绘出他们之间关系的图。在大多数UML模型中,我们可以将这些概念的类型概括为以下几种:类、接口、数据类型、构件。并且,UML还为这些类型起了一个特别的名字,叫做类元。类元是对有实例且有属性形式的结构特征和操作行为特征建模元素的统称。类是一种重要的类元,此外,接口和数据类型以及构件也是。

        虽然一个类图仅仅显示的是系统的类,但是存在一个变量,确切的显示了各个类对象实例的位置,这就是对象图。对象图描述系统在某一个特定时间点上的静态结构,是类图的实例和快照,即类图的各个类在某个时间点上的实例及其关系的静态写照。对象图中包含对象和链。其中对象是类的特定实例,链是类之间关系的实例,表示对象之间的特定关系。

作用:

        由于静态视图主要被用于支持系统的功能性需求,也就是系统提供给最终用户的服务,而类图的作用是对系统的静态视图进行建模。当对系统的静态视图进行建模时,通常是以如下三种方式来使用类图的:为系统的词汇建模;模型化简单的操作;模型化逻辑数据库模式。

        对象图作为系统在某一时刻的快照,是类图中各个类在某一时间点上的实例及其关系的静态写照,可以通过以下两个方面来说明它的作用:说明复杂的数据结构;表示快照中的行为。

类图的组成

类图是由类、接口等模型元素以及他们之间的关系组成的。类图的目的在于描述系统的构成方式,而不是系统是如何协作运行的。类是面向对象系统组织结构的核心。

是对一组具有相同属性、操作、关系和语义事物的抽象。这些事物包括了现实世界中的物理实体、商业事务、逻辑事物、应用事物和行为事物等,甚至还包括纯粹的概念事物。

接口是在没有给出对象实现和状态的情况下对对象行为的描述。通常,在接口中包含一系列操作但是不包含属性,并且它没有外界可见的关联。我们可以通过一个或多个类或构件实现一个接口,并且在每个类中都可以实现接口中的操作。

类与类之间的关系:依赖关系、泛化关系、关联关系、实现关系。

posted @ 2018-11-25 20:35  strawqqhat  阅读(530)  评论(0编辑  收藏  举报
#home h1{ font-size:45px; } body{ background-image: url("放你的背景图链接"); background-position: initial; background-size: cover; background-repeat: no-repeat; background-attachment: fixed; background-origin: initial; background-clip: initial; height:100%; width:100%; } #home{ opacity:0.7; } .wall{ position: fixed; top: 0; left: 0; bottom: 0; right: 0; } div#midground{ background: url("https://i.postimg.cc/PP5GtGtM/midground.png"); z-index: -1; -webkit-animation: cc 200s linear infinite; -moz-animation: cc 200s linear infinite; -o-animation: cc 200s linear infinite; animation: cc 200s linear infinite; } div#foreground{ background: url("https://i.postimg.cc/z3jZZD1B/foreground.png"); z-index: -2; -webkit-animation: cc 253s linear infinite; -o-animation: cc 253s linear infinite; -moz-animation: cc 253s linear infinite; animation: cc 253s linear infinite; } div#top{ background: url("https://i.postimg.cc/PP5GtGtM/midground.png"); z-index: -4; -webkit-animation: da 200s linear infinite; -o-animation: da 200s linear infinite; animation: da 200s linear infinite; } @-webkit-keyframes cc { from{ background-position: 0 0; transform: translateY(10px); } to{ background-position: 600% 0; } } @-o-keyframes cc { from{ background-position: 0 0; transform: translateY(10px); } to{ background-position: 600% 0; } } @-moz-keyframes cc { from{ background-position: 0 0; transform: translateY(10px); } to{ background-position: 600% 0; } } @keyframes cc { 0%{ background-position: 0 0; } 100%{ background-position: 600% 0; } } @keyframes da { 0%{ background-position: 0 0; } 100%{ background-position: 0 600%; } } @-webkit-keyframes da { 0%{ background-position: 0 0; } 100%{ background-position: 0 600%; } } @-moz-keyframes da { 0%{ background-position: 0 0; } 100%{ background-position: 0 600%; } } @-ms-keyframes da { 0%{ background-position: 0 0; } 100%{ background-position: 0 600%; } }