




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、1,Software Design Overview (2) Software Design Stages (3 slides) Program Design -The Traditional Approach (3) calendar Class (3 slides) date Class (2 slides) Implementing the Calendar Class Error Handling -Program Termination (2 slides) -Setting a Flag (3 slides),Chapter 2 Object Design Techniques,C
2、+ Exceptions (3 slides) Object Composition timeCard Class (3 slides) Implementing timeCard Class -Constructor -punchOut() Operator Overloading -With Free Functions (3 slides) -With Friend Functions (2 slides) -Stream I/O Operators Operator Functions time24 Class (5 slides) Member Function Overloadin
3、g -Implementation Summary Slides (15 slides),2,Software Design Overview,A computer program begins with a problem that the client wants solved. The process of building the program starts with an analysis of the problem. It proceeds through a series of stages to produce a product that is reliable and
4、easy to maintain.,3,Software Design Overview,Prior to the standardization of the software development life cycle: Programmers added code to software with little attention to its integration into the system. Over time systems deteriorated and became so difficult to update that programmers had to deve
5、lop new software to replace them.,4,Software Design Stages,Request: Client perceives a need for a software system to solve a problem. A computer consultant undertakes a feasibility study for the project. Analysis: A systems analyst develops the requirements of the system and creates a functional spe
6、cification that includes a list of needs and special requirements.,5,Software Design Stages,Design: Translate the functional specification into an abstract model of the system. Identify the components of the system and develop algorithms that will be used for implementation. Implementation: Use a pr
7、ogramming language and the design specification to code the different components of the system.,6,Software Design Stages,Testing: Check the program for logical and runtime errors and verify that the system meets the specifications of the client. Maintenance: Periodically update of the software to st
8、ay current and to respond to changing needs of the client.,7,Program DesignThe Traditional Approach,The design phase of the software development life cycle translates the functional specifications from the analysis phase into an abstract model. The traditional design approach uses a top-down strateg
9、y. The model views a system as a layered set of subprograms. Execution begins in the main program and information flows in the system through a series of function calls and return values.,8,Program DesignThe Traditional Approach,When the problem becomes too large this approach can fail: The complexi
10、ty overwhelms the ability of a single person to manage the hierarchy of subprograms. Design changes in subprograms near the top of the hierarchy can require expensive, time-consuming changes in the subprograms at lower levels in the chart.,9,Program DesignThe Traditional Approach,10,11,12,13,date Cl
11、ass,14,date Class,15,Implementing the calendar Class,setMonth() : / update the current month void calendar:setMonth(int mm) / verify that mm is a valid monthif (mm 12) throw dateError(calendar setMonth():,mm, invalid month); / set d to new month d.setMonth(mm); ,16,Error handling: Program Terminatio
12、n,Implementing duration() by terminating the program in case of error: time24 time24:duration(const time24 / if t is earlier than the current time, / throw an exception,17,Error handling: Program Termination,if (tTime currTime) cerr time24 duration(): argument is an earlier time endl; exit(1); else
13、return time24(0, tTime-currTime); ,18,Error Handling:Setting a Flag,Implementing duration() with an error flag: time24 time24:duration(const time24,19,Error Handling:Setting a Flag,/ assume that no error will occursuccess = true; / if t is earlier than the current time, / assign false to successif (
14、tTime currTime)success = false; else / successful. assign duration to / returnTime returnTime = time24(0, tTime-currTime); return returnTime; ,20,Error Handling:Setting a Flag,The programmer can have the calling statement check the result of duration() by placing the call within a conditional expres
15、sion. bool success; time24 currTime, nextTime, interval; . interval = currTime.duration(nextTime, success); if (success = false) / check success and deal with an error ,21,C+ Exceptions,22,C+ Exceptions,Implementing duration() by throwing an exception: time24 time24:duration(const time24,23,C+ Excep
16、tions,/ if t is earlier than the current time, / throw an exception if (tTime currTime) throw rangeError( time24 duration(): argument is an earlier time); elsereturn time24(0, tTime-currTime); ,24,Object Composition,Object Composition: refers to a condition that exists when a class contains one or m
17、ore data members that are objects of class type. Class included by composition = supplier class. Class that includes an object by composition = client class.,25,26,27,28,Implementing the timeCard Class: Constructor,Constructor: / use initialization list to initialize / data members. timeCard:timeCar
18、d(const string their syntax is dealt with separately.,32,Operator Overloading- with Free Functions,A free function could be used to compare two class objects.,/ compare two class objects bool equalItem(const className ,33,Operator Overloading- with Free Functions,The same comparison can be made usin
19、g operator overloading.,bool operator= (const className,34,Operator Overloading- With Friend Functions,Overloading an operator as a free function raises efficiency issues: The function is independent of the class Its implementation must use member functions to access the appropriate data members. If
20、 a class does not provide the appropriate access functions, The operator cannot be overloaded as a free function.,35,Operator Overloading- With Friend Functions,C+ allows a free function to be declared as a friend function in the class: A friend function has access to the private members of the clas
21、s. Denoted in the class declaration by placing the keyword friend immediately before its prototype. Despite having access to the private data members, a friend is not a member function of the class.,36,Operator Overloading- Stream I/O Operators,A class can overload the stream operators as friend fun
22、ctions. operator function prototype for each operation: (Output) : istream,37,Assume the string s = Hello and t = World!. The string expression s + t returns a string that is the concatenation of s and t. The op. function for the op. + with arguments lhs and rhs and return type string is,Operator Fu
23、nctions,string operator+ (const string,38,39,40,41,42,43,Member Function Overloading,/ update time by adding a time24 object / or an int time24 / lhs += min,44,Member Function Overloading-Implementation-,/ implement += by using addition with / operands *this and rhs time24 ,45,Summary Slide 1,-The s
24、oftware life cycle consists of: A Request phase An Analysis phase A Design phase An Implementation phase A Testing phase The Maintenance phase -All share equal importance in the Software Development Lifecycle,46,Summary Slide 2,-The request phase -Meet with the client to discuss the needs and requir
25、ements for a software system. -Perform a feasibility study to see if building a software system is cost effective.,47,Summary Slide 3,-The analysis phase -Determine the system requirements. -Systems analyst determines requirements and is the intermediary between the client and the software engineers
26、. -Result: a functional specification of the software system that includes a list of needs and special requirements.,48,Summary Slide 4,-The design phase (continued) -Translate data from the analysis phase into an abstract model of the problem. -Identify the objects which are the building blocks of
27、the program.-Determine how these objects should collaborate and interact to solve the problem.,49,Summary Slide 4a,-The design phase cont-Create the declaration of the classes including their attributes and public member functions. -Describe how the classes are related to each other -Design the algo
28、rithms that allow the classes to effectively interact.,50,Summary Slide 5,-The implementation phase -Convert the design into a program. -Implement the classes independently and verify the action of their member functions. -Implement program units that coordinate object interaction.-code the main pro
29、gram that manages theoverall execution of the software system. -Often, the implementation stage will discover errors or oversights in design.,51,Summary Slide 6,-The Testing Phase -Analysis, design, and implementation phases interact to bring about modifications and corrections to the specifications
30、 and the code.-effective interaction among the phases depends on frequent and systematic testing. -Test the classes and functions which are the individual units of the software system -perform integrative testing to ensure that the units fit together to create a program that runs correctly and effic
31、iently.,52,Summary Slide 7,-Program maintenance phase -Begins as soon as the client installs the system. -The client will identify bugs or features that must be changed or added. -A client may add new hardware and/or find new applications for the software. -Modern software systems must be regularly
32、upgraded or they will eventually become obsolete and unusable.,53,Summary Slide 8,-Handling errors during function execution is an important aspect of program design. -There are three fundamental ways to handle errors: Output an error message and terminate the program.-Generally avoided unless neces
33、sary. Return a Boolean flag from the function call indicating that an error occurred.-Grants the advantage of leaving the decision about how to handle the error to the calling code block. use the C+ exception mechanism.- The best approach.,54,Summary Slide 9,-C+ exceptions are handled by three keywo
34、rds: -try -Function calls and code that may generate an exception are placed in a try block.,55,Summary Slide 9a,-catch -The exception handler. -Outputs an error message and either takes corrective action or terminates the program.,56,Summary Slide 9b,-throw -Bypasses the normal function return mechanism searches chain of previous function calls until it locates a catch block.,57,Summary
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度木工雕刻技藝傳承與勞務(wù)合作合同
- 2025年度旅游管理公司高層管理人員聘用合同
- 二零二五年度茶葉電商平臺(tái)合作合同
- 二零二五年度學(xué)校臨時(shí)教師聘用合同書-體育教練員合作合同
- 2025年度飯店員工績(jī)效考核與薪酬管理合同
- 二零二五年度無固定期限勞動(dòng)合同解除賠償金支付及賠償金執(zhí)行協(xié)議
- 2025年度汽修廠修理工勞動(dòng)合同續(xù)簽與調(diào)整合同
- 二零二五年度彩鋼棚建筑綠色生態(tài)施工合同
- 藝術(shù)團(tuán)發(fā)言稿
- 網(wǎng)絡(luò)安全風(fēng)險(xiǎn)評(píng)估與控制測(cè)試題
- 失語癥的分類及臨床特征
- 循環(huán)流化床鍋爐操作工安全技術(shù)操作規(guī)程模版(3篇)
- 2024院感培訓(xùn)課件
- 2024-2030年中國(guó)稅務(wù)師事務(wù)所行業(yè)管理模式及投資前景展望報(bào)告版
- 2024年全國(guó)高考英語試題及答案-湖南卷
- 《少兒汽車知識(shí)講座》課件
- 部編人教版小學(xué)四年級(jí)下冊(cè)道德與法治全冊(cè)教案及每課教學(xué)反思
- 中建吊籃安拆專項(xiàng)施工方案(專家論證版)
- 《汽車維修接待實(shí)務(wù)》 課件全套 孫麗學(xué)習(xí)情景1-8 汽車維修服務(wù)接待認(rèn)知 -新能源汽車維修接待
- 2020年礦建監(jiān)理工作總結(jié)
- 獸醫(yī)學(xué)英語詞匯【參考】
評(píng)論
0/150
提交評(píng)論