Software Engineering Techniques: Low Level Design Issues For Programming-In-The-Large
Software Engineering Techniques: Low Level Design Issues For Programming-In-The-Large
• Software Quality
• Design by contract
n Pre- and post conditions
n Class invariants
• Ten do
• Ten do nots
• Ease of use: Is the ease of learning how to use the software, operating
it, preparing input data, interpreting results and recovering from
errors.
OOP: Software Engineering Techniques 3
Design By Contract
• Purpose: To increase software quality by giving each part of a
software product certain obligations and benefits.
• Without contract
n All parts of a program take a huge responsibility
n All parts of a program check for all possible error possibilities (called
defensive programming).
n This makes a large program larger and more complicated
• With contracts
n Methods can make assumptions
n Fewer checks for errors possibilities
n This makes a large program simpler.
• Client programmer
n Obligation: Only call push(x) on a non-full stack
n Benefit: Gets x added on top of stack.
• Class programmer
n Obligation: Make sure that x is pushed on the stack.
n Benefit: No need to check for the case that the stack is already full
• Think Win-Win!
• Other issues
n Class invariantss
n Loop invariants
OOP: Software Engineering Techniques 6
Java 1.4's assert Keyword
• An assertion is a boolean expression that a developer
specifically proclaims to be true during program runtime
execution [Source: java.sun.com].
• New to Java 1.4.
• Used for expressing both pre- and postconditions.
• Syntax:
assert expression1;
assert expression1 : expression2;
Evaluate expression1
if true
no further action
else
if expression2 exists
Evaluate expression2 and use the result in a
single-parameter form of the AssertionError
constructor
else
Use the default AssertionError constructor