- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Chapter 5Errors.ppt
Pre- and post-conditions Always think about them If nothing else write them as comments Check them “where reasonable” Check a lot when you are looking for a bug This can be tricky How could the post-condition for area() fail after the pre-condition succeeded (held)? * Stroustrup/Programming/2015 Testing How do we test a program? Be systematic “pecking at the keyboard” is okay for very small programs and for very initial tests, but is insufficient for real systems Think of testing and correctness from the very start When possible, test parts of a program in isolation E.g., when you write a complicated function write a little program that simply calls it with a lot of arguments to see how it behaves in isolation before putting it into the real program (this is typically called “unit testing”) We’ll return to this question in Chapter 26 * Stroustrup/Programming/2015 The next lecture In the next two lectures, we’ll discuss the design and implementation of a complete small program – a simple “desk calculator.” * Stroustrup/Programming/2015 * Chapter 5Errors Bjarne Stroustrup /Programming Abstract When we program, we have to deal with errors. Our most basic aim is correctness, but we must deal with incomplete problem specifications, incomplete programs, and our own errors. Here, we’ll concentrate on a key area: how to deal with unexpected function arguments. We’ll also discuss techniques for finding errors in programs: debugging and testing. * Stroustrup/Programming/2015 Overview Kinds of errors Argument checking Error reporting Error detection Exceptions Debugging Testing * Stroustrup/Programming/2015 Errors “ … I realized that from now on a large part of my life would be spent finding and correcting my own mistakes.” Maurice Wilkes, 1949 When we write programs, errors are natural and unavoidable; the question is, how do we deal with them? Organize software to minimize errors. Eliminate most of the errors we made anyway. Debugging Testing Make sure the remaining errors
您可能关注的文档
- Book 8 Unit 2Part A Let's learn.ppt
- Bootloader及GNU映像机理.ppt
- Brain Korea Scholarship for Graduate Students.ppt
- Bridge Street.ppt
- Building a DICOM Library in C#.ppt
- by Demon Chan Jul 13, 2013.ppt
- by 高乐高.ppt
- By: 林乐琪 谢佳烨 蒋铮 王乙名 郑佳燕 冯桂焕.ppt
- CA project by Choy Nga Ting.ppt
- CABG术后经静脉桥血管开通右冠CTO.ppt
- Chapter 5Linear Inequalities and Linear Programming.ppt
- Chapter 6 Force and Motion II.ppt
- Chapter 6 How to Analyze Investment projects.ppt
- Chapter 6 Simplex-Based Sensitivity Analysis and Duality.ppt
- CHAPTER 6 Transportation.ppt
- Chapter 6 线性规划.ppt
- CHAPTER 6Bond Primer.ppt
- Chapter 7 - The Amebas.ppt
- Chapter 7 Digital Camera Example.ppt
- Chapter 7 Multidimensional Arrays.ppt
文档评论(0)