当前位置: 首页 > article >正文

面向对象设计(大三上)--往年试卷题+答案

目录

1. UML以及相关概念

1.1 动态图&静态图

1.2 交互图

1.3 序列图

1.4 类图以及关联关系

1.4.1类图

1.4.2 关系类型

(1) 用例图中的包含、扩展关系(include & extend)

(2) 类图中的聚合、组合关系(aggragation & composition)

1.5 图对象以及职责划分 boundary/entity/control objects

2. 开发模型与方法

2.1 迭代开发&增量开发

2.2 开发流程以及风险管理 UP & XP

2.3 凝聚力与类设计 cohesion

3. 面向对象设计原则

3.1 6个主要设计原则

4. 实现策略

4.1 自顶向下&自底向上 top-down & bottom-up strategies

4.2 依赖管理

5. 设计模式

5.1 MVC模式 Model View Controller design pattern

5.2 单例模式

6. 质量评估指标

6.1 类之间的耦合性 CBO

6.2 类的响应数 RFC

6.3 类的方法权重 WMC

7. 实例分析与建模

7.1 基于已知信息去建模

(1) 已知用例描述文档,要求绘制序列图

(2) 已知类图,要求绘制序列图

7.2 场景建模

(1) 航班情景

(2) 商店情景

(3) 在线书城情景

(4) 医院情景

(5) 电影院情景

(6) 运动会场景

7.3 代码设计与分析

(1) 单例模式代码撰写

(2) 接口方法更新

(3) 依赖管理&组件构造顺序

8.在PPT中提到但没展开讲的概念

8.1 UML概念

8.1.1 UML图

8.1.1.0 UML所有图的简介

8.1.1.1 状态图 statechart diagram

8.1.1.2 部署图 deployment diagram

8.1.1.3 组件图 component diagram

8.1.2 UML五视图

8.1.3 N元关联 (N-ary Association)

8.1.4 观察者模式 (Observer Pattern)

8.2 分层架构 layered architecture

8.3 螺旋模型 spiral model

8.4 框架中的热点 hotspot

8.5 数据存储 data storage

8.6 对象标识 object identity


补充,部分题前的“【...次】”是综合出现次数。

1. UML以及相关概念

1.1 动态图&静态图

UML diagrams can be described as either dynamic or static. Explain the difference between these two types of diagrams. Name one example of each type. (5%)【22 final】

答案:Dynamic diagrams describe what happens in the object network. example: Sequence Diagram.Static diagrams describe properties the object network can have. example: Class Diagram.动态图描述系统随时间的行为,主要关注交互和过程。例如:时序图。静态图展示系统的结构,主要关注组件及其关系。例如:类图。

1.2 交互图

In modelling with UML, what is the key goal in building interaction diagrams? What models may change as a result of this process? (5%)【22 final】

答案:The purpose of an interaction diagram is to show how objects collaborate over time through method calls and information exchange. Its change will affect the resulting sequence diagram and interaction diagram.

交互图的目的是显示对象如何通过方法调用和信息交换来随时间推移进行协作。它的改变会影响到导致序列图、交互图。

1.3 序列图

单例模式的序列图

Draw 2 interaction diagrams showing a client calling the getInstance method of a singleton class. One diagram should show what happens the first time the method is called and one should show the second time the method is called. (10%)【22 final】

答案:左图展示了第一次调用时创建的instance,有图展示了第二次调用时不再创建新的而是返回同一个instance。

1.4 类图以及关联关系

1.4.1类图

【2次】Given the class diagram below showing an association class (Attempt), give an example in Java code of how these classes could be implemented. Ensure that the implementation allows the record recording of students having multiple attempts on a single module. (5%)【】

答案:Iterative development is where development is organized as a repeated completion of the development activities. Wach iteration of development process will achieve a part of the overall development or potentially refactor a part that has already been completed. Increment development organize development into phases. By adding new functionalities or improving the existing functionalities in prototype. 

迭代开发指循环完成或改进系统的部分,每次迭代完成一个新部分或重构已完成的旧部分。增量开发指将开发划分为小而可管理的prototype模块并逐步增加系统功能,每次给prototype加新功能或改进旧功能。

1.4.2 关系类型

(1) 用例图中的包含、扩展关系(include & extend)

Include关系用于表示一个用例(基用例)包含另一个用例(子用例)的行为。这种关系通常用于抽象出公共的行为,将其放入单独的用例中,然后由其他用例包含。Extend关系则表示一个用例(基用例)可以在某些条件下扩展另一个用例(扩展用例)的行为。基用例本身是完整的,即使没有扩展用例的参与也能完成其功能。

What is the includes relationship? Explain how an includes relationship defined in the use case diagram has an effect on the development of the system. (5%)【22 final】

答案:

Use case inclusion refers one use case may be performed as a part of another.

Effect: improve code reuse and modular design by identifying and extracting common behaviors early in development, ensuring the shared behavior is only developed once.

用例图中的包含关系表示可重用的功能,可被多个用例包含。

影响:通过在开发初期识别通用行为,促进代码重用和模块化设计,确保共享功能只需开发一次。

【2次】Explain the includes and extends relationships in use case modelling.(5%)【22 final & 15 final】

答案:

inclusion指用例作为其他用例的一部分来执行,通过分解并合并公共功能来避免重复。比如alter booking和delete booking都包括display booking。

extends表示在特定条件下用例的扩展可选行为,在不改变原始流的情况下增加了额外的功能。比如如果用户有优惠券,Complete Order可以扩展为Apply Discount。

(2) 类图中的聚合、组合关系(aggragation & composition)

What type of object structure is denoted by the following class diagram? Why might aggregation be more appropriate?(5%)【21 resit】

答案:

•Component is the base class. Assembly and Part are subclasses of Component.

Assembly contains Component objects, which suggests that an assembly can contain multiple components.

In composition, the lifecycle of the Component is tightly bound to the lifecycle of the Assembly. When an Assembly is destroyed, its Component objects are also destroyed. In aggregation, the Component could exist independently of the Assembly, allowing it to be shared across multiple assemblies. This means the components can exist without the whole, making aggregation more suitable if the parts can exist outside of the assembly context.

Component是基础类,Assembly和Part是它的子类。
程序集包含组件对象,这表明程序集可以包含多个组件。

在组合中,组件的生命周期与程序集的生命周期紧密相连。当一个Assembly元素被销毁时,它的Component对象也会被销毁。在聚合中,组件可以独立于程序集存在,允许它在多个程序集之间共享。这意味着组件可以在没有整体的情况下存在,如果部件可以存在于组装上下文之外,则聚合更加合适。

Describe the meaning of aggregation in UML. What are the formal properties of aggregation? (5%)

答案:

Aggregation in UML represents a "whole-part" relationship, where the part can exist independently of the whole. It's a weaker association compared to composition, where the whole class doesn't own the part. The part can exist without the whole, and multiple parts can be associated with one whole. Aggregation is denoted by a hollow diamond at the association end, and the multiplicity of parts is usually greater than one. Aggregation represents a "has-a" relationship, implying that the whole contains the part, but the part's lifecycle is independent.

Formal Properties of Aggregation:

  1. Independent Lifecycles: The part can exist without the whole.
  2. Representation: Depicted by a hollow diamond at the whole end of the association.
  3. Multiplicity: A whole can have multiple parts, but each part belongs to one whole.
  4. Non-strong Ownership: The whole doesn’t own the part, unlike in composition.

UML中的聚合表示“整体-部分”关系,其中部分可以独立于整体存在。与作文相比,这是一种较弱的联系,在作文中,整个班级并不拥有这个部分。局部可以脱离整体而存在,多个部分可以与一个整体相关联。聚合用关联端的空心菱形表示,部分的数量通常大于1。聚合表示一种“有”关系,这意味着整体包含部分,但部分的生命周期是独立的。
聚合的形式性质:
1. 独立的生命周期:部分可以脱离整体而存在。
2. 代表:在协会的整个末端用一个空心钻石来描绘。
3. 多元性:一个整体可以有多个部分,但每个部分都属于一个整体。
4. 非强所有权:整体不拥有部分,不像组成部分。

1.5 图对象以及职责划分 boundary/entity/control objects

Distinguish between boundary, control and entity objects in the context of the Unified Process. (5%)【15 final】

答案:

entity: store data (Represent core data and business logic)

boundary: handle interaction between system and external uses (Handle user interaction and system input/output.)

control: ensure interaction undergo correctly (manage the system’s logic and flow)

实体:存储数据(表示核心数据和业务逻辑)
边界:处理系统与外部用户之间的交互(处理用户交互和系统输入/输出)。
控制:确保交互正确进行(管理系统的逻辑和流程)

【2次】For each of the three class diagrams below (a, b & c), what type of class is being represented? For each explain what this tells us about the class. (5%)【21 resit & 15 final】

答案:

a: email boundary class, acting as an interface to deal with interactions between system and external uses. Under this condition, email boundary may represent an Email UI or API to handle sending and receiving emails.

b: email control class, to handle the logic flow or processing in system, ensuring interactions happen correctly. Under this condition, email control may handle email management.

c: email entity, to maintain data that closely related to system and databases. Under this condition, it may store the content and state of an email.

a:电子邮件边界类,作为处理系统和外部使用之间交互的接口。在这种情况下,email边界可以代表一个email UI或API来处理发送和接收email。

b:邮件控制类,处理系统中的逻辑流或处理,确保交互正确发生。在这种情况下,邮件控制可以处理邮件管理。

c:电子邮件实体,维护与系统和数据库密切相关的数据。在这种情况下,它可以存储电子邮件的内容和状态。

【3次】For each of the three diagrams below (a, b & c), name the type of connection between the classes. What is the difference between b and c? (5%)【16 final & 18 final & 19 final】

答案:

a: a simple association between email and body, meaning that the email class has no responsible for the lifecycle of the body class

b: email class aggregates body class, body class can exist independently of the email class, and the destruction of the email class does not result in the destruction of the body class

c: email class composites of body class, body class depends on email class, and the destruction of the email class would result body class’s destruction

2. 开发模型与方法

2.1 迭代开发&增量开发

【4次】Distinguish between Iterative development and Incremental development. (5%)【22 final】

答案:

Iterative development is where development is organized as a repeated completion of the development activities. Wach iteration of development process will achieve a part of the overall development or potentially refactor a part that has already been completed.

Increment development organize development into phases. By adding new functionalities or improving the existing functionalities in prototype.

迭代开发指循环完成或改进系统的部分,每次迭代完成一个新部分或重构已完成的旧部分。

增量开发指将开发划分为小而可管理的prototype模块并逐步增加系统功能,每次给prototype加新功能或改进旧功能。

【3次】When using modelling in an iterative process it can be difficult to maintain consistency between models and code. What causes this difficulty? Compare and contrast two possible solutions to this problem. (10%)【21 Final & 20 Final & 19 Final】

答案:

In an iterative process, maintaining consistency between models and code is challenging due to frequent changes in both. As the code evolves with each iteration, the models may become outdated or inaccurate, leading to discrepancies. This occurs because models often represent the design at a specific point in time, while the code might reflect ongoing changes.

Two solutions to this problem are model-driven development (MDD) and code generation.Both solutions aim to bridge the gap, but MDD emphasizes design consistency, while code generation focuses on reducing manual discrepancies.

• MDD focuses on keeping models as the primary source of truth, ensuring that any changes to the code are reflected in the models. However, it requires rigorous model management and frequent updates.

• Code generation uses models to automatically generate code, maintaining consistency by reducing manual changes. But this may limit flexibility and control over the final implementation.

在迭代过程中,由于模型和代码的频繁变化,维护两者之间的一致性是具有挑战性的。随着代码不断更迭,模型可能会变得过时或不准确,从而导致差异。这是因为模型通常表示特定时间点的设计,而代码可能反映正在进行的更改。
这个问题的两个解决方案是模型驱动开发(MDD)和代码生成。这两种解决方案都旨在弥合差距,但是MDD强调设计一致性,而代码生成侧重于减少手工差异。

mdd关注于保持模型作为事实的主要来源,确保对代码的任何更改都反映在模型中。然而,它需要严格的模型管理和频繁的更新。

代码生成使用模型自动生成代码,通过减少手工更改来保持一致性。但这可能会限制最终实现的灵活性和控制力。

2.2 开发流程以及风险管理 UP & XP

During the analysis workflow, what is the goal of realizing use cases? What models/diagrams are created or updated as a result of this process? (5%)【22 final】

答案:

The goal is to describe how interacting objects can perform the specified use cases, which involves identifying the classes and objects needed to achieve these interactions

Models: Domain model, Interaction diagrams (sequence diagram), Class diagram (update new attributes and operations).

目标:定义系统如何通过确定所需的交互和组件来实现用例。

模型:域模型、交互图(比如序列图)、类图(更新属性和方法函数)。

Name the five core work flows of the Unified Process (UP). (5%)【19 final】

答案:

1. Requirements: Define what the system must do.
2. Analysis: Analyze the problem domain and behavior.
3. Design: Specify the architecture and components.
4. Implementation: Convert the design into code.
5. Test: Verify functions and fix defects.

1. 需求:定义系统必须做什么。
2. 分析:分析问题域和行为。
3. 设计:指定体系结构和组件。
4. 实现:将设计转换为代码。
5. 测试:验证功能并修复缺陷。
这些工作流迭代地发生,以确保项目的稳定性和完整性。

Describe how the work flows (and the amount of time spent on each work ow) in the Unified Process change as a project moves through various iterations and phases. You should support your explanation with a diagram. (10%)【19 final】

答案:

In the Unified Process (UP), workflows evolve across 4 phases:

1. Inception: Focuses on business modeling & requirements to establish feasibility.

2. Elaboration: Emphasizes analysis & design, refining architecture while reducing risks.

3. Construction: The bulk of implementation & testing occurs, developing a functional system.

4. Transition: Concentrates on deployment & user feedback, ensuring a smooth release.

diagram:

+------------+-------------+-------------+--------------+------------+
| Workflow   | Inception   | Elaboration | Construction | Transition |
+------------+-------------+-------------+--------------+------------+
| Business   | High        | Medium      | Low          | Low        |
| Analysis   | Medium      | High        | Medium       | Low        |
| Design     | Low         | High        | Medium       | Low        |
| Impl/Test  | Low         | Medium      | High         | Medium     |
| Deploy     | None        | Low         | Medium       | High       |
+------------+-------------+-------------+--------------+------------+

【2次】Name the 5 core values of eXtreme Programming (XP). (5%)【18 final & 22 final】

答案:

1. Communication: Open communication between team members.
2. Simplicity: Focus on simple, workable solutions.
3. Feedback: Regular feedback from users and testing.
4. Courage: Take risks and make necessary changes.
5. Respect: Value the contributions of each team member.

1. 沟通:团队成员之间开放的沟通。
2. 简单:专注于简单可行的解决方案。
3. 反馈:来自用户和测试的定期反馈。
4. 勇气:敢于冒险,做出必要的改变。
5. 尊重:重视每个团队成员的贡献。
这些价值有助于指导XP实践并改进软件开发。

【3次】Discuss the importance of testing in large scale software development. In particular, contrast the approaches to testing in the waterfall model and in the unified process. Discuss one risk that the Unified Process minimises in its approach. (10%)【21 resit & 19 final 16 final】

答案:

The importance of testing: Testing can ensure the re


http://www.kler.cn/a/525345.html

相关文章:

  • MySQL备忘录
  • SpringBoot源码解析(八):Bean工厂接口体系
  • python学opencv|读取图像(四十九)原理探究:使用cv2.bitwise()系列函数实现图像按位运算
  • 数据结构选讲 (更新中)
  • React Router v6配置路由守卫
  • 推动知识共享的在线知识库实施与优化指南
  • 多线程【入门】
  • 【学术会议征稿-第二届生成式人工智能与信息安全学术会议(GAIIS 2025)】人工智能与信息安全的魅力
  • ESP32和STM32在处理中断方面的区别
  • Midjourney中的垫图、角色一致、风格一致到底区别在哪
  • Oracle Primavera P6 最新版 v24.12 更新 1/2
  • web前端10--变化
  • jQuery的系统性总结
  • 梯度提升用于高效的分类与回归
  • 55. 常用UDP端口号及其功能
  • lanqiaoOJ 2145:求阶乘 ← 二分法
  • 10.6.1 文本文件读、写和追加
  • Vue.js组件开发-使用Vue3如何实现上传word作为打印模版
  • webAPI -DOM 相关知识点总结(非常细)
  • 常用符号的英语表达
  • MATLAB提供的颜色映射表colormap——伪彩色
  • ES2021+新特性、常用函数
  • 【Qt】06-对话框
  • 人口增长(信息学奥赛一本通-1070)
  • sudoers文件修改格式错误恢复
  • 《机器学习数学基础》补充资料:贝叶斯分类器