tailieunhanh - Lecture Programming principles and practice using C++: Chapter 5 - Bjarne Stroustrup

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. | Chapter 5 Errors Bjarne Stroustrup 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 are not serious. My guess | Chapter 5 Errors Bjarne Stroustrup 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 are not serious. My guess is that avoiding, finding, and correcting errors is 95% or more of the effort for serious software development. You can do much better for small programs. or worse, if you’re sloppy Stroustrup/Programming/2015 Your Program Should produce the desired results for all legal inputs Should give reasonable error messages for illegal inputs Need not worry about misbehaving hardware Need not worry about misbehaving system software Is allowed to terminate after finding an error 3, 4, and 5 are true for beginner’s code; often, we have to worry about those in real software. Stroustrup/Programming/2015 Sources of errors Poor specification “What’s this supposed to do?” Incomplete programs “but I’ll not get around to doing that until tomorrow” Unexpected arguments “but sqrt() isn’t supposed to be called with -1 as its argument” Unexpected input “but the user was supposed to input an integer” Code that simply doesn’t do what it was supposed to do “so fix it!” Stroustrup/Programming/2015 .

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.