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

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

?? 018.htm

?? 21天內(nèi)快速掌握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一区二区三区免费野_久草精品视频
精品噜噜噜噜久久久久久久久试看 | 亚洲图片你懂的| 成人开心网精品视频| 国产日产欧美一区二区视频| 国产精品亚洲专一区二区三区 | 91在线你懂得| 亚洲综合男人的天堂| 欧美午夜精品免费| 日本视频免费一区| 久久亚洲欧美国产精品乐播 | 色国产综合视频| 午夜亚洲国产au精品一区二区| 欧美精品免费视频| 国产原创一区二区| 亚洲欧洲一区二区三区| 欧美中文字幕一区| 精品影视av免费| 国产精品午夜在线观看| 在线免费观看视频一区| 奇米888四色在线精品| 久久久不卡网国产精品一区| 97久久超碰国产精品| 天天影视涩香欲综合网| 久久蜜桃av一区精品变态类天堂| 99久久精品免费| 图片区小说区国产精品视频| 精品88久久久久88久久久| 波多野结衣在线aⅴ中文字幕不卡| 亚洲欧美另类久久久精品| 91精品国产手机| 国产a区久久久| 亚洲国产日日夜夜| 2021久久国产精品不只是精品| 91女人视频在线观看| 麻豆91免费观看| 国产精品久线在线观看| 欧美一区二区女人| 96av麻豆蜜桃一区二区| 美女尤物国产一区| 一区二区在线免费| 久久久久88色偷偷免费| 欧美亚男人的天堂| 波多野结衣在线一区| 黄页网站大全一区二区| 一区二区三区免费网站| 久久精品夜色噜噜亚洲a∨| 欧美综合一区二区三区| 成人免费三级在线| 麻豆国产精品777777在线| 一区二区三区不卡视频| 欧美国产丝袜视频| 日韩欧美一区在线| 欧美午夜电影一区| www.日韩在线| 国产精品一区二区在线观看不卡| 日韩福利视频网| 亚洲国产精品一区二区久久| 国产精品久久久久影视| www日韩大片| 欧美一级xxx| 欧美久久一区二区| 欧美视频精品在线| 一本一道久久a久久精品综合蜜臀| 国产一区二区看久久| 日本va欧美va欧美va精品| 一区二区三区国产豹纹内裤在线| 中文在线资源观看网站视频免费不卡| 欧美成人三级在线| 日韩午夜中文字幕| 91精品黄色片免费大全| 欧美日韩视频在线第一区| 欧美系列在线观看| 欧美午夜片在线观看| 色婷婷av一区二区三区gif| 成人福利视频在线| 成人一级片在线观看| 国产不卡一区视频| 成人深夜福利app| 成人黄色777网| av在线不卡观看免费观看| 成人手机电影网| aa级大片欧美| 在线观看亚洲精品视频| 在线观看av一区二区| 欧洲亚洲国产日韩| 欧美日韩在线综合| 欧美伦理电影网| 日韩免费在线观看| 欧美xxxxx裸体时装秀| 精品999久久久| 国产精品丝袜一区| 亚洲欧美日韩在线播放| 亚洲一区二区三区爽爽爽爽爽| 亚洲综合一区二区精品导航| 五月婷婷色综合| 麻豆一区二区在线| 高清成人在线观看| av电影天堂一区二区在线| 91福利精品第一导航| 91精品国产综合久久蜜臀| 欧美不卡一二三| 国产精品二三区| 亚洲一区二区在线观看视频| 蜜乳av一区二区| 国产精华液一区二区三区| 成人开心网精品视频| 色8久久人人97超碰香蕉987| 欧美日韩日日骚| 精品欧美久久久| 中文字幕一区二区三区不卡| 午夜av电影一区| 成人永久aaa| 欧美乱妇一区二区三区不卡视频| 亚洲精品在线观| 亚洲精品视频自拍| 蜜臀精品久久久久久蜜臀 | aa级大片欧美| 5858s免费视频成人| 久久精品视频免费| 午夜一区二区三区在线观看| 激情综合五月婷婷| 色国产综合视频| 久久欧美一区二区| 亚洲成人一区二区| 国产白丝网站精品污在线入口| 色婷婷综合久色| 久久久精品国产免费观看同学| 樱花草国产18久久久久| 国产又黄又大久久| 欧美色区777第一页| 久久久久久久久一| 亚洲成av人影院| aaa欧美色吧激情视频| 日韩精品一区二区在线| 亚洲一区二区欧美激情| 国产高清亚洲一区| 日韩欧美一二三四区| 亚洲黄色录像片| 成人免费精品视频| 日韩精品一区二区三区四区视频 | 制服丝袜亚洲精品中文字幕| 国产精品久久三| 国产精品一品视频| 欧美一区二区三区四区在线观看| 亚洲欧美日韩国产综合在线| 国产乱人伦精品一区二区在线观看 | 三级在线观看一区二区| 91一区一区三区| 国产色产综合色产在线视频| 日韩国产欧美在线观看| 欧美三级韩国三级日本一级| 国产精品美女久久久久久久| 国产精品乡下勾搭老头1| 日韩一区二区三免费高清| 亚洲午夜在线视频| 一本一道久久a久久精品| 国产精品三级av| 成人免费高清视频在线观看| 久久久亚洲国产美女国产盗摄| 蜜臀久久99精品久久久久宅男 | 欧美伦理影视网| 亚洲一区二区三区不卡国产欧美| 91麻豆国产精品久久| 成人欧美一区二区三区黑人麻豆| 国产成人av电影免费在线观看| 久久综合九色欧美综合狠狠| 麻豆中文一区二区| 欧美成人欧美edvon| 久久99久久99| 精品国产一区久久| 韩国三级电影一区二区| 久久日韩粉嫩一区二区三区| 国产永久精品大片wwwapp| 精品国产免费人成电影在线观看四季| 毛片av中文字幕一区二区| 日韩欧美二区三区| 国产一区二区三区综合| 国产亚洲一区二区在线观看| 国产成人在线视频免费播放| 国产精品免费久久| 色综合久久久久综合| 亚洲韩国精品一区| 91精品国产综合久久久久久久久久 | 国产福利91精品一区| 国产精品免费aⅴ片在线观看| 99r精品视频| 香蕉成人伊视频在线观看| 日韩午夜三级在线| 国产剧情一区二区| 国产精品成人一区二区三区夜夜夜 | 亚洲综合激情网| 6080亚洲精品一区二区| 国产一区不卡精品| 亚洲欧美综合另类在线卡通| 日本高清视频一区二区| 日本视频在线一区| 久久久91精品国产一区二区三区| av电影一区二区| 日本成人中文字幕在线视频 | 日韩精品专区在线影院观看|