TAILIEUCHUNG - Lecture Programming languages (2/e): Chapter 18c - Tucker, Noonan

Chapter 18c - Correctness of object-oriented programs. The main contents of this chapter include all of the following: Design by contract, the class invariant, correctness of a queue application, final observations. | Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming scientifically, it must be possible to specify the required properties of programs precisely. Formality is certainly not an end in itself. The importance of formal specifications must ultimately rest in their utility - in whether or not they are used to improve the quality of software or to reduce the cost of producing and maintaining software. J. Horning Contents Axiomatic Semantics Formal Methods Tools: JML JML Exception Handling Correctness of Object-Oriented Programs Design by Contract The Class Invariant Correctness of a Queue Application Final Observations Correctness of Functional Programs Review JML JML Expression Meaning requires p; p is a precondition for the call ensures p; p is a postcondition for the call signals (E e) p; when exception e is raised by the call, p is a postcondition loop_invariant p; p is a loop invariant invariant p; p is a class invariant \result == e; e is the result returned by the call \old v the value of v at entry to the call (\product int x ; p(x); e(x)) the product of e(x) for all x that satisfy p(x) (\sum int x ; p(x); e(x)) the sum of e(x) for all x that satisfy p(x) p ==> q p q Design by Contract The contract for a Stack class The Class Invariant A class C is formally specified if: 1. Every constructor and public method M in the class has preconditions and postconditions, and 2. C has a special predicate called its class invariant INV which, for every object o in C, argument x and call (x), must be true both before and after the call. Note: During a call, INV may temporarily become false. Why are we doing this??? Formal specifications provide a foundation for rigorous OO system design (., “design by contract”). They enable static and dynamic assertion checking of an entire OO system. They enable formal correctness proof of an OO system. .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.