亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? 018.htm

?? 21天內快速掌握c++語言
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
<HTML><HEAD><meta http-equiv="Content-Type" content="text/html; charset=GB2312"><TITLE>-->Learn C++ in 21 Days-->Day 18</TITLE>
<META NAME="888" CONTENT=" Learn C++ in 21 Days Day 18">
<META NAME="888" CONTENT=" - Learn C++ in 21 Days - Day 18">

<style>
<!--
#page {position:absolute; z-index:0; left:0px; top:0px}
.tt3 {font: 9pt/12pt "宋體"}
.tt2 {font: 12pt/15pt "宋體"}
a {text-decoration:none}
a:hover {color: blue;text-decoration:underline}
-->
</style>
</HEAD>
<p align="center"><script src="../../../1.js"></script> </p>
<TD CLASS="tt3" VALIGN="top" width="8%"  bgcolor="#ffffff"><strong><A HREF="019.htm"><FONT style="FONT-SIZE: 9pt">后一頁</font></A><BR>
<A HREF="017.htm"><FONT style="FONT-SIZE: 9pt">前一頁</font></A><BR>

<A HREF="index.html"><FONT style="FONT-SIZE: 9pt">回目錄</font></A><BR>
 
<TD class="tt2" bgcolor="#ffffff" width="100%"><center><B><FONT style="FONT-SIZE: 16.5pt" COLOR="#FF6666" FACE="楷體_GB2312">Day 18</FONT></B></center>
 
	<LI><A HREF="#Heading1">Day 18</A>
	<UL>
		<LI><A HREF="#Heading2">Object-Oriented Analysis and Design</A>
		<UL>
			<LI><A HREF="#Heading3">The Development Cycle</A>
			<LI><A HREF="#Heading4">Simulating an Alarm System</A>
			<UL>
				<LI><A HREF="#Heading5">Preliminary Design</A>
				<LI><A HREF="#Heading6">What Are the Objects?</A>
				<LI><A HREF="#Heading7">Other Objects</A>
				<LI><A HREF="#Heading8">What Are the Classes?</A>
				<LI><A HREF="#Heading9">How Are Alarms Reported?</A>
				<LI><A HREF="#Heading10">Event Loops</A>
			</UL>
			<LI><A HREF="#Heading11">Listing 18.1. A simple event loop</A><A HREF="#Heading12">.</A>
			<LI><A HREF="#Heading13">PostMaster</A>
			<LI><A HREF="#Heading14">Measure Twice, Cut Once</A>
			<LI><A HREF="#Heading15">Divide and Conquer</A>
			<LI><A HREF="#Heading16">Message Format</A>
			<LI><A HREF="#Heading17">Initial Class Design</A>
			<LI><A HREF="#Heading18">Rooted Hierarchies Versus Non-Rooted Hierarchies</A>
			<UL>
				<LI><A HREF="#Heading19">Figure 18.1.</A>
			</UL>
			<LI><A HREF="#Heading20">Designing the Interfaces</A>
			<UL>
				<LI><A HREF="#Heading21">Building a Prototype</A>
				<LI><A HREF="#Heading22">The 80/80 Rule</A>
			</UL>
			<LI><A HREF="#Heading23">Designing the PostMasterMessage Class</A>
			<UL>
				<LI><A HREF="#Heading24">Application Program Interface</A>
			</UL>
			<LI><A HREF="#Heading25">Listing 18.2. PostMasterMessages interface</A><A HREF="#Heading26">.</A>
			<UL>
				<LI><A HREF="#Heading27">Programming in Large Groups</A>
				<LI><A HREF="#Heading28">Ongoing Design Considerations</A>
			</UL>
			<LI><A HREF="#Heading29">Design Decisions</A>
			<UL>
				<LI><A HREF="#Heading30">Decisions, Decisions</A>
			</UL>
			<LI><A HREF="#Heading31">Working with Driver Programs</A>
			<LI><A HREF="#Heading32">Listing 18.3. A driver program for PostMasterMessage</A><A
			HREF="#Heading33">.</A>
			<LI><A HREF="#Heading34">Summary</A>
			<LI><A HREF="#Heading35">Q&amp;A</A>
			<LI><A HREF="#Heading36">Workshop</A>
			<UL>
				<LI><A HREF="#Heading37">Quiz</A>
				<LI><A HREF="#Heading38">Exercises</A>
			</UL>
		</UL>
	</UL>
</UL>
<BR>
<P>
<HR SIZE="4">
<BR>
<H2 ALIGN="CENTER"><A NAME="Heading1"></A><FONT COLOR="#000077">Day 18</FONT></H2>
<H2 ALIGN="CENTER"><A NAME="Heading2"></A><FONT COLOR="#000077">Object-Oriented Analysis
and Design</FONT></H2>
<P>It is easy to become focused on the syntax of C++ and to lose sight of how and
why you use these techniques to build programs. Today you will learn
<BR>
<UL>
	<LI>How to analyze problems from an object-oriented perspective.
	<P>
	<LI>How to design your program from an object-oriented perspective.
	<P>
	<LI>How to design for reusability and extensibility.
</UL>
<BR>
<H3 ALIGN="CENTER"><A NAME="Heading3"></A><FONT COLOR="#000077">The Development Cycle</FONT></H3>
<P>Many volumes have been written about the development cycle. Some propose a &quot;waterfall&quot;
method, in which designers determine what the program should do; architects determine
how the program will be built, what classes will be used, and so forth; and then
programmers implement the design and architecture. By the time the design and architecture
is given to the programmer, it is complete; all the programmer needs to do is implement
the required functionality.</P>
<P>Even if the waterfall method worked, it would probably be a poor method for writing
good programs. As the programmer proceeds, there is a necessary and natural feedback
between what has been written so far and what remains to be done. While it is true
that good C++ programs are designed in great detail before a line of code is written,
it is not true that that design remains unchanged throughout the cycle.</P>
<P>The amount of design that must be finished &quot;up front,&quot; before programming
begins, is a function of the size of the program. A highly complex effort, involving
dozens of programmers working for many months, will require a more fully articulated
architecture than a quick-and-dirty utility written in one day by a single programmer.</P>
<P>This chapter will focus on the design of large, complex programs which will be
expanded and enhanced over many years. Many programmers enjoy working at the bleeding
edge of technology; they tend to write programs whose complexity pushes at the limits
of their tools and understanding. In many ways, C++ was designed to extend the complexity
that a programmer or team of programmers could manage.</P>
<P>This chapter will examine a number of design problems from an object-oriented
perspective. The goal will be to review the analysis process, and then to understand
how you apply the syntax of C++ to implement these design objectives.
<H3 ALIGN="CENTER"><A NAME="Heading4"></A><FONT COLOR="#000077">Simulating an Alarm
System</FONT></H3>
<P>A simulation is a computer model of a part of a real-world system. There are many
reasons to build a simulation, but a good design must start with an understanding
of what questions you hope the simulation will answer.</P>
<P>As a starting point, examine this problem: You have been asked to simulate the
alarm system for a house. The house is a center hall colonial with four bedrooms,
a finished basement, and an under-the-house garage.</P>
<P>The downstairs has the following windows: three in the kitchen, four in the dining
room, one in the half-bathroom, two each in the living room and the family room,
and two small windows next to the door. All four bedrooms are upstairs, each of which
has two windows except for the master bedroom, which has four. There are two baths,
each with one window. Finally, there are four half-windows in the basement, and one
window in the garage.</P>
<P>Normal access to the house is through the front door. Additionally, the kitchen
has a sliding glass door, and the garage has two doors for the cars and one door
for easy access to the basement. There is also a cellar door in the backyard.</P>
<P>All the windows and doors are alarmed, and there are panic buttons on each phone
and next to the bed. The grounds are alarmed as well, though these are carefully
calibrated so that they are not set off by small animals or birds.</P>
<P>There is a central alarm system in the basement, which sounds a warning chirp
when the alarm has been tripped. If the alarm is not disabled within a setable amount
of time, the police are called. If a panic button is pushed, the police are called
immediately.</P>
<P>The alarm is also wired into the fire and smoke detectors and the sprinkler system,
and the alarm system itself is fault tolerant, has its own internal backup power
supply, and is encased in a fireproof box.
<H4 ALIGN="CENTER"><A NAME="Heading5"></A><FONT COLOR="#000077">Preliminary Design</FONT></H4>
<P>You begin by asking, &quot;What questions might this simulation answer?&quot;
For example, you might be able to use the simulation to answer the questions, &quot;How
long might a sensor be broken before anyone notices?&quot; or &quot;Is there a way
to defeat the window alarms without the police being notified?&quot;</P>
<P>Once you understand the purpose of the simulation you will know what parts of
the real system the program must model. Once that is well understood, it becomes
much easier to design the program itself.
<H4 ALIGN="CENTER"><A NAME="Heading6"></A><FONT COLOR="#000077">What Are the Objects?</FONT></H4>
<P>One way to approach this problem is to set aside issues relating to the user interface
and to focus only on the components of the &quot;problem space.&quot; A first approximation
of an object-oriented design might be to list the objects that you need to simulate,
and then to examine what these objects &quot;know&quot; and &quot;do.&quot;</P>
<BR>
<DL>
	<DD>
<HR>
<FONT COLOR="#000077"><B>New Term:</B></FONT><B> </B>The <I>problem space</I> is
	the set of problems and issues your program is trying to solve. The solution space
	is the set of possible solutions to the problems.
<HR>
<BR>
</DL>
<BR>
<P>For example, clearly you have sensors of various types, a central alarm system,
buttons, wires, and telephones. Further thought convinces you that you must also
simulate rooms, perhaps floors, and possibly groups of people such as owners and
police.</P>
<P>The sensors can be divided into motion detectors, trip wires, sound detectors,
smoke detectors, and so forth. All of these are types of sensors, though there is
no such thing as a sensor per se. This is a good indication that sensor is an abstract
data type (ADT).</P>
<P>As an ADT, the class sensor would provide the complete interface for all types
of sensors, and each derived type would provide the implementation. Clients of the
various sensors would use them without regard to which type of sensor they are, and
they would each &quot;do the right thing&quot; based on their real type.</P>
<P>To create a good ADT, you need to have a complete understanding of what sensors
do (rather than how they work). For example, are sensors passive devices or are they
active? Do they wait for some element to heat up, a wire to break, or a piece of
caulk to melt, or do they probe their environment? Perhaps some sensors have only
a binary state (alarm state or okay), but others have a more analog state (what is
the current temperature?). The interface to the abstract data type should be sufficiently
complete to handle all the anticipated needs of the myriad derived classes.
<H4 ALIGN="CENTER"><A NAME="Heading7"></A><FONT COLOR="#000077">Other Objects</FONT></H4>
<P>The design continues in this way, teasing out the various other classes that will
be required to meet the specification. For example, if a log is to be kept, probably
a timer will be needed; should the timer poll each sensor or should each sensor file
its own report periodically?</P>
<P>The user is going to need to be able to set up, disarm, and program the system,
and so a terminal of some sort will be required. You may want a separate object in
your simulation for the alarm program itself.
<H4 ALIGN="CENTER"><A NAME="Heading8"></A><FONT COLOR="#000077">What Are the Classes?</FONT></H4>
<P>As you solve these problems, you will begin to design your classes. For example,
you already have an indication that <TT>HeatSensor</TT> will derive from <TT>Sensor</TT>.
If the sensor is to make periodic reports, it may also derive via multiple inheritance
from <TT>Timer</TT>, or it may have a timer as a member variable.</P>
<P>The <TT>HeatSensor</TT> will probably have member functions such as <TT>CurrentTemp()</TT>
and <TT>SetTempLimit()</TT> and will probably inherit functions such as <TT>SoundAlarm()</TT>
from its base class, <TT>Sensor</TT>.</P>
<P>A frequent issue in object-oriented design is that of encapsulation. You could
imagine a design in which the alarm system has a setting for <TT>MaxTemp</TT>. The
alarm system asks the heat sensor what the current temperature is, compares it to
the maximum temperature, and sounds the alarm if it is too hot. One could argue that
this violates the principle of encapsulation. Perhaps it would be better if the alarm
system didn't know or care what the details are of temperature analysis; arguably
that should be in the <TT>HeatSensor</TT>.</P>
<P>Whether or not you agree with that argument, it is the kind of decision you want
to focus on during the analysis of the problem. To continue this analysis, one could
argue that only the <TT>Sensor</TT> and the <TT>Log</TT> object should know any details
of how sensor activity is logged; the <TT>Alarm</TT> object shouldn't know or care.</P>
<P>Good encapsulation is marked by each class having a coherent and complete set
of responsibilities, and no other class having the same responsibilities. If the
sensor is responsible for noting the current temperature, no other class should have
that responsibility.</P>
<P>On the other hand, other classes might help deliver the necessary functionality.
For example, while it might be the responsibility of the <TT>Sensor</TT> class to
note and log the current temperature, it might implement that responsibility by delegating
to a <TT>Log</TT> object the job of actually recording the data.</P>
<P>Maintaining a firm division of responsibilities makes your program easier to extend
and maintain. When you decide to change the alarm system for an enhanced module,
its interface to the log and to the sensors will be narrow and well defined. Changes
to the alarm system should not affect the <TT>Sensor</TT> classes, and vice versa.</P>
<P>Should the <TT>HeatSensor</TT> have a <TT>ReportAlarm()</TT> function? All sensors
will need the ability to report an alarm. This is a good indication that <TT>ReportAlarm()</TT>
should be a virtual method of <TT>Sensor</TT>, and that <TT>Sensor</TT> may be an
abstract base class. It is possible that <TT>HeatSensor</TT> will chain up to <TT>Sensor</TT>'s
more general <TT>ReportAlarm()</TT> method; the overridden function would just fill
in the details it is uniquely qualified to supply.
<H4 ALIGN="CENTER"><A NAME="Heading9"></A><FONT COLOR="#000077">How Are Alarms Reported?</FONT></H4>
<P>When your sensors report an alarm condition, they will want to provide a lot of
information to the object that phones the police and to the log. It may well be that
you'll want to create a <TT>Condition</TT> class, whose constructor takes a number
of measurements. Depending on the complexity of the measurements, these too might
be objects, or they might be simple scalar values such as integers.</P>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久一区二区三区捆绑**| 亚洲成人免费影院| 亚洲第一二三四区| 国产成人a级片| 日韩天堂在线观看| 亚洲视频一区在线观看| 久久成人免费日本黄色| 欧美午夜精品一区二区蜜桃| 欧美激情在线看| 另类小说一区二区三区| 色婷婷精品久久二区二区蜜臀av| 婷婷久久综合九色综合绿巨人| 国产精品1024久久| 日韩亚洲欧美在线观看| 午夜视频在线观看一区二区| 成人精品免费视频| 欧美成人一区二区三区| 天天色综合成人网| 欧美日韩午夜在线视频| 亚洲色图第一区| 91视频在线观看免费| 久久久午夜电影| 777欧美精品| 午夜精品成人在线视频| 91久久精品网| 亚洲欧美国产高清| 91在线视频18| 国产精品国产精品国产专区不蜜| 国产精品资源在线看| 日韩午夜在线观看视频| 美国十次了思思久久精品导航| 欧美精品免费视频| 天堂一区二区在线| 亚洲免费av高清| 色综合 综合色| 亚洲美女淫视频| 欧美日韩在线一区二区| 日韩福利电影在线| 91精品一区二区三区在线观看| 亚洲国产精品综合小说图片区| 在线观看视频一区二区欧美日韩| 亚洲欧美激情一区二区| 在线观看视频一区二区| 日韩一区精品字幕| 婷婷国产在线综合| 8v天堂国产在线一区二区| 日本美女视频一区二区| 精品久久久久久久人人人人传媒 | 亚洲一区二区综合| 欧美日韩国产在线播放网站| 香蕉成人啪国产精品视频综合网| 欧美欧美午夜aⅴ在线观看| 裸体歌舞表演一区二区| 欧美国产1区2区| 色婷婷久久久亚洲一区二区三区| 亚洲一级在线观看| 亚洲国产精品影院| 精品久久久久香蕉网| www.亚洲色图.com| 亚洲国产日日夜夜| 欧美精品一区二区三区久久久| 成人免费高清在线观看| 亚洲国产另类精品专区| 久久久精品人体av艺术| 色素色在线综合| 精品一区二区三区在线观看国产| 国产精品久久免费看| 欧美人与禽zozo性伦| 国产在线精品不卡| 一区二区免费在线| 久久久久久久久99精品| 色哟哟国产精品免费观看| 久久精工是国产品牌吗| 久久久久久久久免费| 成人av免费在线| 日本成人中文字幕| 亚洲久本草在线中文字幕| 精品国产乱码久久久久久夜甘婷婷 | 色综合久久久久综合99| 美女脱光内衣内裤视频久久网站 | 久久精品网站免费观看| 99精品在线免费| 久久av老司机精品网站导航| 亚洲欧美偷拍卡通变态| 精品国产sm最大网站免费看| 色成年激情久久综合| 国产aⅴ综合色| 蜜桃视频第一区免费观看| 一区二区三区不卡视频| 国产欧美日韩麻豆91| 日韩三级视频中文字幕| 欧美视频在线一区二区三区 | 国产乱码精品一区二区三区忘忧草| 亚洲麻豆国产自偷在线| 久久久久久久久99精品| 欧美xxxxx裸体时装秀| 欧美午夜精品一区| 欧美伊人久久大香线蕉综合69| 国产成人久久精品77777最新版本 国产成人鲁色资源国产91色综 | 亚洲香蕉伊在人在线观| 一色屋精品亚洲香蕉网站| 久久综合九色综合97婷婷| 91精品国产91久久久久久最新毛片| 91在线云播放| 99re66热这里只有精品3直播 | 在线视频欧美精品| 色综合色狠狠天天综合色| 成人激情校园春色| 成人激情黄色小说| 波多野结衣中文字幕一区二区三区| 精品一二三四区| 久久99热99| 国产河南妇女毛片精品久久久| 蜜桃av一区二区三区| 免费久久99精品国产| 免费成人小视频| 奇米一区二区三区| 蜜桃av噜噜一区| 黑人巨大精品欧美黑白配亚洲| 麻豆国产精品一区二区三区| 三级精品在线观看| 蜜桃视频在线一区| 国产精品77777| 成人黄色国产精品网站大全在线免费观看 | 久久亚洲精精品中文字幕早川悠里| 欧美大片免费久久精品三p| 欧美成人免费网站| 久久精品人人做人人综合| 国产精品少妇自拍| 亚洲人快播电影网| 午夜精品成人在线视频| 蜜桃av一区二区三区电影| 黄页视频在线91| 成人国产电影网| 在线观看网站黄不卡| 538在线一区二区精品国产| 日韩女优视频免费观看| 久久久电影一区二区三区| 自拍偷拍亚洲激情| 亚洲成人免费视频| 精品亚洲国内自在自线福利| 成人丝袜高跟foot| 精品1区2区3区| 久久久久88色偷偷免费| 亚洲精品视频在线看| 日韩精品91亚洲二区在线观看 | 久久免费精品国产久精品久久久久| 国产精品区一区二区三区| 亚洲男人天堂一区| 另类小说视频一区二区| 99国产精品99久久久久久| 日韩一区二区三区视频在线 | 亚洲国产日韩a在线播放| 久色婷婷小香蕉久久| www.亚洲色图| 日韩欧美一级二级三级久久久| 中文字幕乱码亚洲精品一区| 亚洲国产精品久久久久秋霞影院 | 久久久久久久久久久电影| 亚洲一区二区免费视频| 国产综合色在线视频区| 在线观看av不卡| 欧美激情一区二区三区四区| 婷婷丁香久久五月婷婷| 99久久精品免费观看| 精品久久久久久综合日本欧美| 亚洲精品视频在线观看免费| 国产精品自在在线| 欧美绝品在线观看成人午夜影视| 国产欧美精品一区二区色综合| 亚洲第一福利视频在线| 99re热视频精品| 久久久蜜桃精品| 蜜桃av噜噜一区| 欧美日韩一区二区在线观看视频 | 久久久久久夜精品精品免费| 一个色综合av| 99久久精品一区| 久久蜜桃av一区精品变态类天堂 | 成人97人人超碰人人99| 精品免费99久久| 日韩精品成人一区二区在线| 91老师国产黑色丝袜在线| 久久久久国产精品厨房| 精品一区二区三区在线视频| 欧美久久一区二区| 亚洲成a人片综合在线| 色欧美乱欧美15图片| 亚洲欧洲在线观看av| 国产成人a级片| 欧美国产一区二区在线观看| 国模无码大尺度一区二区三区| 日韩一区二区精品| 日韩精品一二三区| 欧美精品黑人性xxxx| 首页欧美精品中文字幕| 欧美日韩和欧美的一区二区| 亚洲精品网站在线观看| 色综合婷婷久久| 亚洲小说欧美激情另类|