问题 单项选择题

设计模式使人们可以更加简单方便地复用成功的设计和体系结构。将已证实的技术表述成设计模式也会使新系统开发者更加容易理解其设计思路。一个模式有4个基本要素,它们是 (48) ,设计模式中的Factory属于 (49)

(49)处填()。

A.结构模式

B.创建模式

C.行为模式

D.抽象模式

答案

参考答案:B

解析:

在面向对象的编程中,软件编程人员更加注重以前的代码的重用性和可维护性。 设计模式使人们可以更加简单方便地复用成功的设计和体系结构。将已证实的技术表述成设计模式也会使新系统开发者更加容易理解其设计思路。

一般而言,一个模式有以下4个基本要素。

(1)模式名称(Pattern Name)。一个助记名,它用一两个词来描述模式的问题、解决方案和效果。命名一个新的模式增加了我们的设计词汇。设计模式允许在较高的抽象层次上进行设计。基于一个模式词汇表,自己以及同事之间就可以讨论模式并在编写文档时使用它们。模式名可以帮助我们思考,便于与其他人交流设计思想及设计结果。找到恰当的模式名也是设计模式编目工作的难点之一。

(1)问题(Problem)。描述了应该在何时使用模式。它解释了设计问题和问题存在的前因后果,它可能描述了特定的设计问题,如怎样用对象表示算法等。也可能描述了导致不灵活设计的类或对象结构。有时候,问题部分会包括使用模式必须满足的一系列先决条件。

(3)解决方案(Solution)。描述了设计的组成成分,它们之间的相互关系及各自的职责和协作方式。因为模式就像一个模板,可应用于多种不同场合,所以解决方案并不描述一个特定而具体的设计或实现,而是提供设计问题的抽象描述和怎样用一个具有一般意义的元素组合(类或对象组合)来解决这个问题。

(4)效果(Consequences)。描述了模式应用的效果及使用模式应权衡的问题。尽管描述设计决策时并不总提到模式效果,但它们对于评价设计选择和理解使用模式的代价及好处具有重要意义。软件效果大多关注对时间和空间的衡量,它们也表述了语言和实现问题。因为复用是面向对象设计的要素之一,所以模式效果包括它对系统的灵活性、扩充性或可移植性的影响,显式地列出这些效果对理解和评价这些模式很有帮助。

设计模式主要有创建模式、结构模式、行为模式,这之中最为基础和著名的应该就是 Factory。

填空题
完形填空

根据短文内容,从短文后的选项中选出能填入空白处的最佳选项,选项中有两项为多余选项.

小题1:  You probably think you will never be a top student. This is not necessarily so, however. Anyone can become a better scholar if he or she wants to. Here's how :

Plan your time carefully. When planning your work, you should make a list of things that you have to do. After making the list, you should make a schedule of your time. First your time for eating, sleeping, dressing, etc. Then decide on a good, regular time for studying.  小题2: A weekly schedule may not solve all your problems, but it will force you to realize what is happening to your time.

Find a good place to study. Look around the house for a good study area. Keep this space , which may be a desk or simply a corner of your room, free of everything but study materials. No games, radios, or television! When you sit down to work, concentrate on the subject!

Make good use of your time in class.  小题3:. Listening carefully in class means less work later. Taking notes will help you remember what the teacher says.

Study regularly. When you get home from class, go over your notes. Review the important points that your teacher is going to discuss the next day, read that material.  小题4: If you do these things regularly, the material will become more meaningful, and you will remember it longer.

Develop a good attitude about tests. The purpose of a test is to show what you have learned about a subject. They help make your new knowledge. The world won’t end if you don’t pass a test, so don’t be over worried.

小题5: You will probably discover many others after you have tried these.

There are other methods that might help you with your study.

Don’t forget to set aside enough time for entertainment

Take advantage of class time to listen to everything the teacher says.

No one can become a top student unless he or she works hard.

Maybe you are an average student.

Make full use of class time to take notes of what the teacher says in class.

This will help you understand the next class.