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

Chapter 18b - Formal Methods Tools: JML. In this section, we introduce the features of JML as they apply to the formal specification and verification of an individual function, such as the Factorial function that we specified and verified by hand in the previous section. We also show how JML allows us to specify run-time exceptions, providing a more robust vehicle than the pure Hoare triples in a real computational setting where exceptions actually occur. | 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 Stack Application Final Observations Correctness of Functional Programs Background OO systems focuses on classes and objects Methods and messages are subordinate The state of a system is the set of all active objects and their values at any moment of run time. Formal specifications P and Q are therefore logical expressions about an object’s state. Tools for formal specifications: Specifications : Java Modeling Language (JML) Design: Unified Modeling Language (UML) and JML Coding: Java and JML Verification: Java and JML Specifications in OO Programs Where? Method level: pre- and post-conditions, loop invariants Class level: class invariant (class state) System level: intra-class invariants (system state) When (in the OO design process)? Specification and design phases: Write specifications for all classes and methods (UML/JML) Coding phase: Develop code from the specifications (UML/JML/Java) Verification phase: Prove that specifications and code are equivalent (JML/Java) What is JML? () History Emerged in early 2000s out of ESC/Java2 Goals Infuse formal methods into the software process Make formal specification accessible to programmers Provide direct support for “design by contract” methodology Integrate with a real language (Java) JML is a language for writing . | 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 Stack Application Final Observations Correctness of Functional Programs Background OO systems focuses on classes and objects Methods and messages are subordinate The state of a system is the set of all active objects and their values at any moment of run time. Formal specifications P and Q are therefore .

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.