CPS 209 Lecture Notes - Lecture 3: Liskov Substitution Principle, Postcondition, Standard Streams

88 views8 pages

Document Summary

Every method always has a set of pre- and postconditions: describing what it is supposed to achieve and in what circumstances. aka: what it means and what it intends to do. Method implementation: encapsulated in a black box to the caller caller can only see the end results once the method has terminated. These pre/post conditions cannot actually be expressed in java: these are semantic properties expressed in comments + (javadoc) documentation of the method. Design by contract vs defensive programming: both are valid to check pre-conditions the first minimizes code; the latter maximizes safety. What if the superclass method is abstract and has no implementation? it can still define pre- and post- conditions these must be adhered to by the subclasses. Inheritance should model an is-a relationship between the 2 concepts. this is a semantic property and cannot be enforced by the compiler.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents