prepost - PRE & POST What's the big picture? The pre-...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
What's the big picture? The pre- and postconditions should tell, at an abstract level, what a method does. Think abstraction! We should be able to look at the function header, the PRE, and the POST, and know what the function does, without having to know its implementation (i.e. the internal details). The PRE and POST form a contract. Think of it this way: if the preconditions of a method are met, then it is guaranteed to produce the postconditions stated. My hope with this guide is to help you with most things you'd need to document, but understand its not exhaustive, as each function is unique and writing is inherently a skill that requires critical thinking. In general, though, with PRE/POST, you need to think about the following: The parameters Files the method works with Anything that is returned Anything that happens as a result of the method When you've written PRE/POST, step back and pretend you didn't write the function. Think about what questions you'd have. What kinds of parameters and where do I document them? There are three classes of parameters: Input parameters , i.e. those that send information into the function (generally passed by value) Output parameters , i.e. those that the function changes, but the function does not do anything with the initial values (must be passed by reference) Input/Output parameters , i.e. those that send information into the function and are also changed by the function (must be passed by value) Here's where you document them: Input parameters Must have meaningful values for the function to work, so they must be documented in the
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

prepost - PRE & POST What's the big picture? The pre-...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online