Lecture Data structures and other objects using C++ - Chapter 1: Preconditions and postconditions

This is the first of several lectures which accompany the textbook Data Structures and other objects using C++. Each lecture chooses one topic from the book and expands on that topic - adding examples and further material to reinforce the students' understanding. This first lecture covers the topic of preconditions and postconditions from chapter 1. | An important topic: preconditions and postconditions. They are a method of specifying what a function accomplishes. Preconditions and Postconditions Data Structures and Other Objects Using C++ This is the first of several lectures which accompany the textbook Data Structures and Other Objects Using C++. Each lecture chooses one topic from the book and expands on that topic - adding examples and further material to reinforce the students' understanding. This first lecture covers the topic of Preconditions and Postconditions from Chapter 1. Preconditions and Postconditions Frequently a programmer must communicate precisely what a function accomplishes, without any indication of how the function does its work. Can you think of a situation where this would occur ? Throughout the book, preconditions and postconditions are used to specify precisely what a function does. However, as we will see, a precondition/postcondition specification does not indicate anything about how a function accomplishes its work. This separation between what a function does and how the function works is extremely important - particularly for large programs which are written by a team of programmers. Example You are the head of a programming team and you want one of your programmers to write a function for part of a project. HERE ARE THE REQUIREMENTS FOR A FUNCTION THAT I WANT YOU TO WRITE. I DON'T CARE WHAT METHOD THE FUNCTION USES, AS LONG AS THESE REQUIREMENTS ARE MET. As an example, suppose that you are the head of a programming team. Your team is writing a large piece of software, perhaps with millions of lines of code. Certainly nobody can keep all those lines of code in their head at once (not even me!). So, the large problem is broken into smaller problems. Those smaller problems might be broken into still smaller problems, and so on, until you reach manageable problems. Each of the manageable problems can be solved by a function - but you won't be writing all these functions. The . | An important topic: preconditions and postconditions. They are a method of specifying what a function accomplishes. Preconditions and Postconditions Data Structures and Other Objects Using C++ This is the first of several lectures which accompany the textbook Data Structures and Other Objects Using C++. Each lecture chooses one topic from the book and expands on that topic - adding examples and further material to reinforce the students' understanding. This first lecture covers the topic of Preconditions and Postconditions from Chapter 1. Preconditions and Postconditions Frequently a programmer must communicate precisely what a function accomplishes, without any indication of how the function does its work. Can you think of a situation where this would occur ? Throughout the book, preconditions and postconditions are used to specify precisely what a function does. However, as we will see, a precondition/postcondition specification does not indicate anything about how a function .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã 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.