首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
In looking at the class structure of an entire system, we may find that its inheritance (1) is either wide and shallow, narrow a
In looking at the class structure of an entire system, we may find that its inheritance (1) is either wide and shallow, narrow a
admin
2009-09-04
21
问题
In looking at the class structure of an entire system, we may find that its inheritance (1) is either wide and shallow, narrow and deep, or balanced. Class structures that are wide and shallow usually represent forests of (2) classes that can be mixed and matched. Class structures that are narrow and deep represent trees of classes that are related by a common ancestor. There are advantages and disadvantages to each approach. Forests of classes are more loosely (3) , but they may not exploit all the commonality that exists. Trees of classes exploit this commonality, so that individual classes are smaller than in forests. However, to understand a particular class, it is usually necessary to understand the meaning of all the classes it inherits from or uses. The proper shape of a class structure is highly problem-dependent. We must make similar trade-offs among inheritance, aggregation, and using relation- ships. For example, should the class Car inherit, contain, or use the classes named Engine and Wheel? In this case, we suggest that an (4) relationship is more appropriate than inheritance relationship. Meyer states that between the class A and B," (5) is appropriate if every instance of B may also be viewed as an instance of A. The client relationship is appropriate when every instance of B simply possesses one or more attributes of A". From another perspective, if the behavior of an object is more than the sum of its individual parts, then creating an aggregation relationship rather than an inheritance relationship between the appropriate classes is probably superior.
选项
A、aggregation
B、inheritance
C、association
D、using
答案
B
解析
译文如下:在查看整个系统的类结构时,会发现它的继承层次或者是宽而浅,或者是窄而深,或者是均衡的。宽而浅的类结构通常表示一些可被混合和匹配的自由独立的类组成的类森林。窄而深的类结构,表示由公共的祖先相关联的类树。每种方法都有优缺点。类的森林的耦合度较低,但它们可能不能体现出存在的所有共同处。类树体现出这种共同处,所以它的类个体比类森林中的类要小。但是为了理解某个特定的类,通常需要理解它所继承的或使用的类的含义。类结构的形状是否恰当与特定问题紧密相关。我们必须在继承、聚合和使用这三个关系中选择使用合适的。例如,类Car是继承、还是包含、还是使用类Engine和类Wheel呢?在这种情况下,聚合关系比继承关系更合适。Meyer建议在类A和类B之间,“如果B的每个实例也可被看做A的一个实例,那么继承较为合适。如果B的每个实例只处理A的一个或多个属性,则客户关系更为合适一些”。从另外一个角度看,如果一个对象的行为多于它的单个部分的总和,那么在适当的类间创建聚合关系比继承关系更合适。
转载请注明原文地址:https://kaotiyun.com/show/erxZ777K
本试题收录于:
软件设计师上午基础知识考试题库软考中级分类
0
软件设计师上午基础知识考试
软考中级
相关试题推荐
在CSMA中,决定退让时间的算法为:①如果信道空闲,以户的概率发送,而以(1-p)的概率延迟一个时间单位t;②如果信道忙,继续监听直至信道空闲并重复步骤①;③如果发送延迟了一个时间单位t,则重复步骤①。上述算法为(14)。
在Linux系统的路由配置中,若设置静态路由,则需(17)命令。在使用该命令时为了防止出现错误,可以将网络名字代替网络号,而网络名字可以在文件(18)中定义。为了将手工配置的命令存储下来,在系统启动时自动执行,可以通过(19)来实现。若运行动态路由,则(2
Microsoft’sCOMisasoftwarearchitecturethatallowsapplicationstobebuiltfrombinarysoftwarecomponents.COMistheunde
公开密钥加密是一种(43)。常用的公钥加密算法有(44),它的一个比较知名的应用是(45),这种应用的协商层用公钥方式进行身份认证,记录层涉及到对应用程序提供的信息的分段、压缩、数据认证和加密。
FDDI(光纤分布式数据接口)的基本编码方法是(168),在此基础上采用(169)编码,编码效率提高到(170)。
阅读以下说明,回答下面问题。【说明】二层隧道协议L2TP(1ayer2TunnelingProtocol)是一种基于点对点协议PPP的二层隧道协议。某网络结构如图3.3所示,采用L2TP来实现网络安全。
当一台主机从一个网络移到另一个网络时,以下说法正确的是(26)。
有关UDP协议说法不正确的是(25)。
两个人利用Netphone通话时,对语言格式的解释是由(19)完成的。
子网过滤防火墙安装方法是把防火墙安装在一个由(1)控制边界的公共子网中,子网中有一台执行(2)的主机,对于多数应用入口,需要一个附加的(3)机制来控制、筛选入口与网络之间的信息流。这样可以有效地把该机制和(4)结合起来,达到多层屏障保护的目的。
随机试题
A.营养支持时间在2周以内B.营养支持时间在2周以上C.将多种自然食物混合成半液体状膳食D.人工配置的各种分子水平的营养成分E.用静脉途径输入生理需要的全部营养要素完全胃肠外营养为
A.可伴有失血性休克B.可有呕血、黑粪C.可有腹膜后积气D.早期常只有局限性腹膜炎E.可出现膈下游离气体结肠破裂
初孕妇,30岁,妊娠38+3周,诊断为中度妊娠高血压综合征。待产过程中发生抽搐,护士应首要采取的措施是
糖皮质激素对血细胞数目的影响是
《水利工程建设重大质量与安全事故应急预案》属于( )应急预案。
在客户法人治理结构评价中,对客户控股股东行为评价需考虑的关键因素有()。
简述工作岗位评价指标的构成。
“蓬生麻中,不扶自直,白沙在涅,与之俱黑”反映了对人的发展有重要影响的是()。
英文大写字母D的ASCII码值为44H,英文大写字母F的ASCH码值为十进制数
Alectureisnot【D1】______Useabbreviations,symbols,numbersandsoontotakenotesinorderto【D2】______.【D3】______
最新回复
(
0
)