CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program...

69
CS 101 Chapter 1: Background Aaron Bloomfield

Transcript of CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program...

Page 1: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

CS 101

Chapter 1: BackgroundAaron Bloomfield

Page 2: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Let’s begin

• Goal– Teach you how to program effectively

• Skills and information to be acquired– Mental model of computer and network behavior– Problem solving– Object-oriented design– Java

Page 3: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

What is a computer?

• Not a rhetorical question!• “A device that computes…

especially a programmable electronic machine that performs high-speed mathematical or logical operations or that assembles, stores, correlates, or otherwise processes information”– From American Heritage® Dictionary of the English

Language, 4th Edition

Page 4: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

So what is a computation?

• The act or process of computing– Duh!

• Definition of computing:– To determine by the use of a computer– To determine by mathematics, especially by numerical

methods: computed the tax due• My revised definition for computing:

– The act of taking a problem with specific inputs and determining a specific answer (output)

Page 5: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Axiom

• By definition, a (properly functioning) computer will always produce the same output given the same input

• So how do we compute random numbers?

Page 6: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

The first computers

• Scales – computed relative weight of two items– Computed if the first item’s weight was less than, equal to, or

greater than the second item’s weight• Abacus – performed mathematical computations

– Primarily thought of as Chinese, but also Japanese, Mayan, Russian, and Roman versions

– Can do square roots and cube roots

Page 7: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Stonehenge

Page 8: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

88

Computer SizeComputer Size

ENIAC then…

ENIAC today…

With computers (small) size does matter!With computers (small) size does matter!

Page 9: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

So what do we do with a computer now that we have one?

• We have to tell a computer what to do– Computers have no intelligence of their own

• We tell a computer what to do by writing a computer program– In this course, we’ll use Java

Page 10: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Algorithms

• What is an algorithm?• “A step-by-step problem-solving procedure,

especially an established, recursive computational procedure for solving a problem in a finite number of steps”– From American Heritage® Dictionary of the English

Language, 4th Edition

• We’ve seen lots of algorithms before…

Page 11: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Example algorithm: map directions

Page 12: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Example algorithm: car radio removal

Page 13: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Example algorithm: Recipes

Page 14: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Bad algorithms

• Not all algorithms are “good”

• So then what makes an algorithm “bad”?

Page 15: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Bad algorithms: MapQuest directions

• Consider directions to get around grounds

Page 16: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.
Page 17: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Note that this is not an incorrect algorithm!Note that this is not an incorrect algorithm!Just a Just a veryvery inefficient one inefficient one

Page 18: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Bad algorithms: Shampoo directions

Page 19: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.
Page 20: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Bad algorithms: Shampoo directions

• Lather, rinse, repeat

• This algorithm repeats forever!– Note that humans know to not to spend forever performing the

algorithm– But computers do not!

• Remember, they have zero intelligence

• Hence the overplayed computer joke:– How did the computer scientist die in the shower?– He read the directions: lather, rinse, repeat

Page 21: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Bad algorithms: Inexact recipes

Page 22: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Our goal

• Is to write correct and efficient algorithms for a computer to follow– Remember that computers are dumb!

• We aren’t going to worry about the efficient part in this course

• But what does “correct” mean?

Page 23: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

“Correct” algorithms

• Consider an algorithm to display the color blue

• Is this blue?

• Is this blue?

• What about this?

• And this one?

Definitely

Also, yes: two correct results!

Maybe (could be green)

Definitely not

Page 24: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Note that this is not an incorrect algorithm!Note that this is not an incorrect algorithm!Just a Just a veryvery inefficient one inefficient one

Page 25: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

So what does all this mean?

• Humans specify algorithms without a lot of precision– Display the color “blue”– Get me from “here” to “there”– When there isn’t much precision, there are often multiple answers

• Computers need more precision– Display the color 0x0000ff (royal blue):

• There is only one possible outcome– Find the shortest route from “here” to “there”

• We need to be very specific when we specify things to a computer– Computers are dumb!

Page 26: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Onto the book chapter

• A lot of this terminology will be confusing at first– We will be going over it in more detail throughout the

semester

Page 27: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Computer Organization

Input Devices

CentralProcessing Unit

Memory

Output Devices

Page 28: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

• Computer advertisement specification– Intel® Pentium 4 Processor

at 3.06GHz with 512K cache– 512MB DDR SDRAM– 200GB ATA-100 Hard Drive

(7200 RPM, 9.0 ms seek time)– 17” LCD Monitor– 64MB NVIDIA GeForce4

MX Graphics Card®– 16x Max DVD-ROM Drive– 48x/24x/48x CD-RW Drive– 56K PCI Telephony Modem– Windows XP Home Edition®– 10/100 Fast Ethernet Network Card

• – Intel® Pentium 4 Processor

at 3.06GHz with 512K cache– 512MB DDR SDRAM– 200GB ATA-100 Hard Drive

(7200 RPM, 9.0 ms seek time)– 17” LCD Monitor– 64MB NVIDIA GeForce4

MX Graphics Card®– 16x Max DVD-ROM Drive– 48x/24x/48x CD-RW Drive– 56K PCI Telephony Modem– Windows XP Home Edition®– 10/100 Fast Ethernet Network Card

Computer Organization

3.06 billion operationsper second

512 million bytes ofmemory that can betransferred at double

the normal rate

A byte is 8 bits

A bit is a 0 or a 1

Stores 200 billionbytes of data. You want high RPM and

low seek time.0.009 seconds is

average

17” on the diagonal.Resolution up to1,280 by 1,024

pixels

Microprocessor fordisplaying images with

64 million bytes ofmemory. More memorysupports more colorsand higher resolution

Reads DVDs 16 timesfaster than a basic DVD

drive. Can hold up to8 billion bytes of data

Can read and writeCDs. Can hold 650

million bytes of dataReads at 48 timesfaster and writes

24 times faster thana basic drive

Can send or receiveup to 56 thousand

bits per second

Computer operatingsystem using a

graphical interface

Can send or receivedata at two rates –

10 or 100 million bytesper second

Page 29: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

3030

A bit of humor: Computer A bit of humor: Computer OrganizationOrganization

Why I like adding humorous Why I like adding humorous bits into class…bits into class…

Page 30: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Home network

ISP

Router

LaptopComputer

Cable modem

Internet

Page 31: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Backbones

Page 32: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

3333

A bit of humor…A bit of humor…

Page 33: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Network communication

• Communication protocol– Set of rules that govern how data is sent and received

• TCP/IP– Exchanging packets of information over the Internet

• FTP– Exchanging files between computes

• SMTP– Exchanging email over the Internet

• POP– Exchanging email between mail reader and the ISP

• HTTP– Exchanging files over the WWW

• SSL– How information is to be encrypted

Page 34: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

First Programming Languages

• Ada Lovelace (1833)– Programmed of Babbage’s analytical engine

• ENIAC (1945)– Programmed by plugging wires

• Binary– 100100010101001010101010

• Assembly• FORTRAN (1954)

Page 35: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Java’s Direct Lineage

• C (1972) by Dennis Ritchie

• C++ (1985) by Bjarne Stroustrup

• Java (1991) by James Gosling and others at Sun Microsystems

Page 36: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Computing units of measure

• A bit is either a 1 or a 0– On or off, true or false, etc.

• A byte is 8 bits:– 01001010– As there are 8 bits per byte, each byte can hold 28=256 values– 01001010 = 74

• All computing measurements are in terms of bytes

Page 37: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Computing units of measure

• Kilo (K) = 1,000 (thousand)• Mega (M) = 1,000,000 (million)• Giga (G) = 1,000,000,000 (billion)• Tera (T) = 1,000,000,000,000 (trillion)• Kilo = 210 = 1,024• Mega = (1024)2 = 1,048,576• Giga = (1024)3 = 1,073,741,824• Tera = (1024)4 = 1,099,511,627,776

= Kibi (Ki)

= Mebi (Mi)

= Gibi (Gi)

= Tebi (Ti)

Page 38: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Computing units of measure

• An unformatted text document (such as a Java program)– 3 pages per kilobyte (1,000 bytes)

• A formatted document (such as a Word file)– About 5k per page with formatting

• A digital camera picture– About 1 Mb each (1,000,000 bytes)

• An MP3 music file– 5 Mb for a 5 minute song

• A music file on a CD– 50 Mb for a 5 minute song– 10 times the size of an MP3!

• A movie clip– About 10 Mb per minute of (TV-sized) video

Page 39: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

A marketing trick

• This hard drive has 250,059,350,016 bytes– = 250.06 Gigabytes– = 232.89 Gibibytes

• Guess which one they use to advertise the drive?

Page 40: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Software

• Program– Sequence of instruction that tells a computer what to do

• Execution– Performing the instruction sequence

• Programming language– Language for writing instructions to a computer

• Major flavors– Machine language or object code– Assembly language– High-level

Program to which computer can respond

directly. Each instructionis a binary code that

corresponds to anative instruction

Symbolic languagefor coding machine

language instructions

Detailed knowledge ofthe machine is notrequired. Uses avocabulary and

structure closer to theproblem being solved

Java is a high-levelprogramming

language

For program to beexecuted it must be

translated

Page 41: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Translation

• Translator– Accepts a program written in a source language and translates it

to a program in a target language

• Compiler– Standard name for a translator whose source language is a high-

level language

• Interpreter– A translator that both translates and executes a source program

Page 42: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Java translation

• Two-step process

• First step– Translation from Java to bytecode

• Bytecodes are architecturally neutral object code• Bytecodes are stored in a file with extension .class

• Second step– An interpreter translates the bytecodes into machine instructions

and executes them• Interpreter is known a Java Virtual Machine or JVM

Page 43: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Programming Task

• Display the forecast

I think there is a world market for maybe five computers. Thomas Watson, IBM, 1943.

Page 44: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

DisplayForecast.java

// Authors: J. P. Cohoon and J. W. Davidson// Purpose: display a quotation in a console window

public class DisplayForecast {

// method main(): application entry point public static void main(String[] args) { System.out.print("I think there is a world market for"); System.out.println(" maybe five computers."); System.out.println(" Thomas Watson, IBM, 1943.");

}}

Three statements make up the action of method main()

Method main() is part of class DisplayForecast

A method is a named piece of code that performs some action or implements a behaviorAn application program is required to have a public static void method named main().

Page 45: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Sample output

Page 46: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Java Documentation

• Familiarize yourself with the Java documentation– It will save you lots of time!

• A link to it is on the website– We will go over it in a future lab as well

Page 47: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Good Commenting

• Necessary so others can re-use your code– And so the graders can understand it!

• A well commented program:

// Authors: J. P. Cohoon and J. W. Davidson// Purpose: display a quotation in a console window

public class DisplayForecast {

// method main(): application entry point public static void main(String[] args) { System.out.print("I think there is a world market for"); System.out.println(" maybe five computers."); System.out.println(" Thomas Watson, IBM, 1943.");

}}

Page 48: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Bad commenting

// Thomas J. Watson (February 17, 1874 - June 19, 1956) is

// considered to be the founder of IBM. He was one of the

// richest men of his time and called the world's greatest

// salesman when he died.

// Watson was born in Campbell, New York. His formal

// education consisted of only a course in the Elmira

// School of Commerce. His first job was at age 18 as

// a bookkeeper in Clarence Risley's Market in Painted

// Post, New York. Later he sold sewing machines and

// musical instruments before joining the National Cash

// Register Company as a salesman in Buffalo. He eventually

// worked his way up to general sales manager. Bent on

// inspiring the dispirited NCR sales force, Watson

// introduced the motto, "THINK," which later became

// a widely known symbol of IBM.

// Although he is well known for his alleged 1943 statement:

// "I think there is a world market for maybe five computers"

// there is no evidence he ever made it. The author Kevin

// Maney tried to find the origin of the quote. He has been

// unable to locate any speeches or documents of Watson's

// that contain this, nor is it present in any contemporary

// articles about IBM. The earliest known citation is from

// 1986 on Usenet in the signature of a poster from Convex

// Computer Corporation as "I think there is a world market

// for about five computers" --Remark attributed to Thomas

// J. Watson (Chairman of the Board of International

// Business Machines),1943

// While at NCR, he was convicted for illegal anti-

// competitive sales practices (e.g. he used to have

// people sell deliberately faulty cash registers, either

// second-hand NCR or from competitors; soon after the

// second-hand NCR or competitors cash register failed,

// an NCR salesperson would arrive to sell them a brand

// new NCR cash register). He was sentenced, along with

// John H. Patterson (the owner of NCR), to one year of

// imprisonment. Their conviction was unpopular with the

// public, due to the efforts of Patterson and Watson to

// help those affected by the 1913 Dayton, Ohio floods,

// but efforts to have them pardoned by President Woodrow

// Wilson were unsuccessful. However, the Court of

// Appeals overturned the conviction on appeal in 1915,

// on the grounds that important defense evidence should

// have been admitted.

public class DisplayForecast {

// method main(): application entry point

public static void main(String[] args) {

System.out.print("I think there is a world market for");

System.out.println(" maybe five computers.");

System.out.println(" Thomas Watson, IBM, 1943.");

}

}

Page 49: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

More bad commenting

• From the context-switching code of Unix V6 (file: slp.c)

/* * If the new process paused because it was * swapped out, set the stack level to the last call * to savu(u_ssav). This means that the return * which is executed immediately after the call to aretu * actually returns from the last routine which did * the savu. * * You are not expected to understand this. */

if(rp->p_flag&SSWAP) { rp->p_flag =& ~SSWAP; aretu(u.u_ssav);}

• Source: http://www.tuhs.org/Archive/PDP-11/Trees/V6/usr/sys/ken/slp.c

Page 50: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Java and the Internet

I think ...

JVMJava

Compiler

DisplayForecast.java

DisplayForecast.class DisplayForecast.class

Modem Modem

Your machine Your friend's machine

Internet

Page 51: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Engineering software

• Complexity of software grows as attempts are made to make it easier to use– Rise of wizards

Page 52: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Software engineering

• Goal– Production of software that is effective and reliable,

understandable, cost effective, adaptable, and reusable

• Goal– Production of software that is effective and reliable,

understandable, cost effective, adaptable, and reusable

• Work correctly and not fail

• Goal– Production of software that is effective and reliable,

understandable, cost effective, adaptable, and reusable

• Because of the long lifetime many people will be involved– Creation– Debugging– Maintenance – Enhancement

• Two-thirds of the cost is typically beyond creation

• Goal– Production of software that is effective and reliable,

understandable, cost effective, adaptable, and reusable

• Cost to develop and maintain should not exceed expected benefit

• Goal– Production of software that is effective and reliable,

understandable, cost effective, adaptable, and reusable

• Design software so that new features and capabilities can be added

• Goal– Production of software that is effective and reliable,

understandable, cost effective, adaptable, and reusable

• Makes sense due to the great costs involved to have flexible components that can be used in other software

Page 53: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Separate components into external and internal

aspects

Construct a system fromcomponents and packages

Ranking or ordering of objects

Principles of software engineering

• Abstraction

• Encapsulation

• Modularity

• Hierarchy

• Abstraction

• Encapsulation

• Modularity

• Hierarchy

Determine the relevant properties and features

while ignoring nonessential details

• Abstraction

• Encapsulation

• Modularity

• Hierarchy

• Abstraction

• Encapsulation

• Modularity

• Hierarchy

• Abstraction

• Encapsulation

• Modularity

• Hierarchy

Page 54: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

5555

A bit of humor:A bit of humor:1989 Computer1989 ComputerAdvertisementAdvertisement

Guess the price!

Page 55: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Object-oriented design

• Purpose– Promote thinking about software in a way that models

the way we think and interact with the physical word• Including specialization

• Object– Properties or attributes– Behaviors

Page 56: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Programming

• Class – Term for a type of software object

• Object– An instance of a class

with specific properties and attributes

Page 57: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Programming

• Problem solving through the use of a computer system

• Maxim– You cannot make a computer do something if you do not

know how to do it yourself

Page 58: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Problem Solving

• Why do you care?– We are all assigned tasks to do

• At work• At home• At school

• Why not do them– Right– Efficiently

Page 59: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Problem Solving

• Why care about computer-based problemsolving (i.e., programming)?

– Neat– Frontier of science– Profitable– Necessary– Quality of life

Page 60: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Problem Solving

• Remember– The goal is not a clever solution but a correct solution

• Accept– The process is iterative

• In solving the problem increased understanding might require restarting

• Solutions– Often require both concrete and abstract thinking

• Teamwork

Page 61: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Problem Solving Process

• What is it?– Analysis– Design– Implementation– Testing

• – Analysis– Design– Implementation– Testing

Determine the inputs, outputs, and other components of the problem

Description should be sufficiently specific to allow you to solve the problem

Describe the components and associated processes for solving the problem

Straightforward and flexible

Method – process

Object – component and associated methods

Develop solutions for the components and use those components to produce an overall solution

Straightforward and flexible

Test the components individually and collectively

Page 62: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Problem Solving Process

Testing

Design

Analysis

Implementation

Determineproblem features

Describe objectsand methods

Produce theclasses and code

Examine forcorrectness

Rethink asappropriate

Page 63: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Tips

• Find out as much as you can

• Reuse what has been done before

• Expect future reuse

• Break complex problems into subproblems

Page 64: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Tips

• Find out as much as you can

• Reuse what has been done before

• Expect future reuse

• Break complex problems into subproblems

Find out what is known about the problem

Talk to the presenter

Determine what attempts have succeeded and what attempts have failed

Research can require significant time and generate questions

The effort is worthwhile because the result is a better understanding

True understanding of the problem makes it easier to solve

Consider

Sketching a solution and then repeatedly refine its components until the entire process is specified

Page 65: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Tips

• Find out as much as you can

• Reuse what has been done before

• Expect future reuse

• Break complex problems into subproblems

Your time is valuable

Correctness is probably even more valuable

Use existing infrastructure that is known to work

Be open to indirect use of existing materials

Page 66: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Tips

• Find out as much as you can

• Reuse what has been done before

• Expect future reuse

• Break complex problems into subproblems

Make as few assumptions as necessary

Maximizes the likelihood that your effort can be used in future situations

Page 67: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Tips

• Find out as much as you can

• Reuse what has been done before

• Expect future reuse

• Break complex problems into subproblems

Divide-and-conquer

Solve subproblems and combine into an overall solution

Page 68: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

Tips

• Read– Problem solving texts

• George Polya, How to Solve It; A New Aspect of Mathematical Method,Princeton Press, 1988

• Wayne Wickelgren, How to Solve Mathematical Problems, Dover Publications, 1995

• Paul Zeitz, The Art and Craft of Problem Solving, John Wiley, 1999– Sociological examination of different problem solving styles

• Sherry Turkle and Seymour Papert, Epistemological Pluralism: Styles and Voices Within the Computer Culture, Signs: A Journal of Women in Culture and Society, 1990

Page 69: CS 101 Chapter 1: Background Aaron Bloomfield. Let’s begin Goal –Teach you how to program effectively Skills and information to be acquired –Mental model.

7070

Today’s demotivatorsToday’s demotivators