3

Right now I'm reading Code Complete by Steve McConnell and in chapter 9 he talks about the Pseudo Programming Process (PPP).

From what I've understood, the PPP is a way of programming in which the programmer first writes the pseudo code for the routine he's working on, then refines it up to the point where pretty much each pseudo code line can be implemented in 1-3 lines of code, then writes the code in the designated programming language and finally the pseudo code is saved as comments for the purpose of documenting the routine.

In chapter 9.4 the author mentions alternatives to the PPP, one of which is 'design by contract'. In design by contract you basically assert preconditions and postconditions of each routine.

Now why would that be considered an alternative? To me it seems obvious that I should use both techniques at the same time and not chose one over the other.

2 Answers 2

2

Design by contract approaches the problem from a different angle. Design by contract starts with describing the allowable program state at certain points, such as the beginning and ends of methods, and enforcing it. Languages like Eiffel have been built from the ground up with this in mind.

Theoretically, if the state has been specified completely by the contracts, the program logic may be derivable. In practise, it becomes executable unit tests included with the application.

PPP, by comparison, is a top-down way of arriving at the code by only dealing with a level of abstraction the developer is comfortable with and slowly decomposing it. PPP deals with the "how" at increasingly lower levels of detail whereas design by contract focuses on the "what" first.

0

I think its the intent of the concepts. In both cases, you're describing what the code will do before writing it. In PPP you're describing the logic that will be utilised to make the functions work, in the other you're describing the functions themselves. I'd say one is just a "higher level" description.

I think that you could use both, but if you did you'd probably realise one or the other was pretty much redundant given the descriptions provided by the other.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.