|
Overview
For years computer programmers have created
programs with formal syntax and informal semantics. They have
produced nicely formatted programs with imprecise comments documenting
more the structure of the code than the semantics. This book
presents frequently encountered problems and reviews them within
the context of semantics to arrive at better solutions. It is
language independent. The authors use it as a supplement to a
standard first course programming textbook in the CS1 course.
This books focus is on program content
rather than form. The approach is to use assertions to reflect
properties of a programs state or semantic content. Admittedly
the use of assertions is not new. But what is new is the semantically-based
approach to the use of assertions.
There are two aspects of persuasive programming:
the semantics of program statements and the integration of the
semantics into the text of a program. The first can be learned,
the second must be experienced. The authors approach to
presenting statement semantics is to determine for each statement
type a pattern of assertions that describes the semantics. The
book works from the obvious pattern (often the most clumsy) and
then, analyzing examples, works its way toward a more useful
pattern.
Persuasive programming is a tool that can
be used with either of the leading programming paradigms (structured
programming or object-oriented programming). With practice, it
becomes quite natural.
|