Chapter 1 Program Development Asserting Java © Rick Mercer.

15
Chapter 1 Program Development Asserting Java © Rick Mercer

Transcript of Chapter 1 Program Development Asserting Java © Rick Mercer.

Chapter 1 Program Development

Asserting Java © Rick Mercer

Program Development

Goals • Understand an example of program

development• Understand the characteristics of a

good algorithm• Understand how algorithmic patterns

can help design programs

1.1 Program Development

Program development can be defined in three steps:• Analysis: Understand the problem• Design: Organize the solution• Implementation: Get the solution running

Program development is the progression from analysis to design to implementation

Analysis

Synonyms for analysis• inquiry, examination, study

Activities• Read and understand the problem

statement• Determine test cases

Test Cases

A program to compute your weighted average

Course Grade from our syllabus

15% Labs35% Projects15% Test 115% Test 220% Final

Determine three test cases:Labs Projects

Test 1 Test 2 Final Average

Design

Synonyms of design: model, think, plan, devise, pattern, propose, outline

We'll use these design tools:• algorithms• algorithmic patterns• algorithm walkthroughs

Algorithms

An algorithm is a set of activities that solves a problem

An algorithm must:• list activities that must be performed• list the activities in the proper order

Algorithm to Bake a Cake

A recipe (a.k.a. an algorithm)• Preheat Oven• Grease Pan• Mix ingredients• Place ingredients into pan• place pan in oven• remove pan after 35 minutes

Switch some activities around ... what happens if …

Algorithmic Patterns

Pattern: Anything shaped or designed to serve as a model or guide in making something else.

Algorithmic Pattern: • Serves as a guide to help develop programs • It represents a common type of action that

occurs over and over again in programs• A solution that can be used different

contexts The Input/Process/Output (IPO)

Pattern can be used.• This IPO pattern will be used in our second

lab and our first project and quite often in the future

IPO Algorithmic Pattern

Pattern: Input/Process/Output (IPO)Problem: The program requires input

datato generate the desired

informationOutline: 1. obtain input data from user

2. process input data3. output the results

Patterns ala Alexander

"Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice."

From A Pattern Language, Christopher Alexander, Oxford University Press, 1977

Example of Algorithm Design

The design deliverable will be an algorithm

The IPO patterns provides a guide to design a more specific algorithm :

IPO Model IPO applied to Chapter 1 Case Study

I)nput Obtain the items that count for 127A

P)rocess Compute the course grade O)utput Display the course grade

Refining Activities in algorithms

We often need to refine one or more activities (algorithm steps). • For example, Compute the course grade

might now be refined with the mathematical addition + and multiplication * symbols

Implementation

Synonyms for Implementation• accomplishment, making good, execution

Implementation deliverable: computer program

Let's do it

We'll use the programming language Java

We'll use the Eclipse Development Environment

One test case with the math done

15% Labs 50 * .15 = 7.535% Projects 60 * .35 = 21.015% Test 1 70 * .15 = 10.515% Test 2 80 * .15 = 12.020% Final 90 * .15 = 13.5

In this test case, the weighted average is

7.5 + 21.0 + 10.5 + 12.0 + 13.5 = 64.5