Program
Design
Going from a problem to a program
Chapter 1 in the text — Read it!!
The Software Life Cycle
• In industry, a software product is expected to be used
for an extended period of time
–
by someone who did not write the program and
–
who is not intimately familiar with its internal design
• Software products go through several stages as
they mature from initial concept to finished product
• The person who maintains the software is not
necessarily the person who writes it
• It is important to design and document software
–
in an organized way
–
so that it can be easily understood and maintained after
the initial release.
Waterfall Model of software life cycle
Problems with the Waterfall Model
• Waterfall model is simple but unworkable
– Fundamental flaw is assumption that each stage can and
must be completed before the next one occurs
• Sometimes, it is not until the product is finished
that the user can fully express his or her requirements
A closer
look at some life cycle activities
• Requirements Specification
–
System analyst
works with software users to clarify the detailed system requirements
–
Questions include
format of input data, desired form of any output screens, and data validation
• Analysis
–
Make sure you
completely understand the problem before starting the design or program a
solution
–
Evaluate
different approaches to the design
• Design
–
Top-down
approach: breaking a system into a
set of smaller subsystems
–
Object-oriented
approach: identification of a set of
objects and specification of their interactions
Using abstraction to help with design
• An abstraction is a model of a physical entity
or activity
–
Abstraction helps
programmers deal with complex issues in a piecemeal fashion
• Procedural abstraction: distinguish what is to be achieved by a procedure
from its implementation
• Data abstraction: specify the data objects for a problem and the operations to be
performed on them without concern for their representation in memory
• Information hiding: Concealing the details of a class implementation from users of the
class
Abstract Data Types
• A major goal of software engineering is to write reusable
code
•
One way to make
code reusable is to encapsulate the data with the methods that
manipulate the data
•
Abstract data
type (ADT): The combination of
data together with the methods that manipulate the data.
– By manipulate we mean change the data, retrieve it,
print it, etc.
•
Then a user of
the Abstract Data Type can use the ADT without being concerned with HOW
the methods were implemented.
Abstract Data Types & Java Interfaces
• A Java interface is a way to specify an ADT
–
The interface
specifies the names, parameters, and return values of the ADT methods
–
It does not
specify how the methods perform their operations and
–
Does not specify
how the data is internally represented
• Each class that implements an interface must provide
the definitions of all methods declared in the interface.
• A Java interface is a contract between the
interface designer and the programmer who codes a class that implements the
interface.
Pre- and Postconditions
• Precondition:
a statement of any assumptions or constraints on the method data before the
method begins execution
• Postcondition:
a statement that describes the result of executing a method
Designing a program
• First step in analysis is to study the problem of input
and output requirements carefully to make sure they are understood and make
sense
•
This is where we
start: we want to write a program to
provide users with an
electronic phone directory.
• What sorts of questions do we ask the users?
– We are trying to get the requirements here.