CS 101-E: Introduction

Post on 09-Jan-2016

26 views 0 download

Tags:

description

CS 101-E: Introduction. Aaron Bloomfield MEC 205 MEC 215 Clark G004 (really). Assumptions. The following is assumed for students in 101-E You have taken a course-equivalent in programming Thus, you know the basics of programming - PowerPoint PPT Presentation

Transcript of CS 101-E: Introduction

1

CS 101-E: Introduction

Aaron Bloomfield

MEC 205MEC 215

Clark G004 (really)

2

Assumptions The following is assumed for students in 101-E

You have taken a course-equivalent in programming Thus, you know the basics of programming

You did not get a 4 or a 5 on the AP computer science exam (AB level)

3

Differences with 101 Labs must be done by all 101-E students on their own time

If you miss more than 2, you are subject to failure Labs due 8:30 p.m. on Sunday Lab session for 101-E students Sunday at 7 p.m.

Pace through the textbook is the same We’ll go into more detail, though Today’s class will be a high-level overview

4

A bit of humor: Review of last time

5

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)

= Kibi (Ki)= Mebi (Mi)= Gibi (Gi)= Tebi (Ti)

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

6

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?

7

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

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 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 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

8

A bit of humor: Input methods

9

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

10

Java translation Two-step process

First step Translation from Java to bytecodes

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

11

Task Display the forecast

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

12

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().

13

Sample output

14

Java Documentation Familiarize yourself with the Java documentation

It will save you lots of time!

15

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.");

}}

16

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.");

}

}

17

Java and the Internet

I think ...

JVMJava

Compiler

DisplayForecast.java

DisplayForecast.class DisplayForecast.class

Modem Modem

Your machine Your friend's machine

Internet

18

Engineering software Complexity of software grows as attempts are made to make

it easier to use Rise of wizards

19

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

20

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

Separate components into external and internal

aspects

Abstraction

Encapsulation

Modularity

Hierarchy

Construct a system fromcomponents and packages

Abstraction

Encapsulation

Modularity

Hierarchy

Ranking or ordering of objects

21

A bit of humor:1989 ComputerAdvertisement

Guess the price!

22

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

23

Programming Class

Term for a type of software object

Object An instance of a class with specific properties and

attributes

24

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

25

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

26

Problem Solving Why care about computer-

based problemsolving (i.e., programming)?

Neat Frontier of science Profitable Necessary Quality of life

27

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

28

Problem Solving Process What is it?

29

Problem Solving Process What is it?

Analysis Design Implementation Testing

30

Problem Solving Process What is it?

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

31

Problem Solving Process What is it?

Analysis Design Implementation Testing

Describe the components and associated processes for solving the problem

Straightforward and flexible

Method – process

Object – component and associated methods

32

Problem Solving Process What is it?

Analysis Design Implementation Testing

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

Straightforward and flexible

33

Problem Solving Process What is it?

Analysis Design Implementation Testing

Test the components individually and collectively

34

Problem Solving Process

Testing

Design

Analysis

Implementation

Determineproblem features

Describe objectsand methods

Produce theclasses and code

Examine forcorrectness

Rethink asappropriate

35

Problem Solving Methodologies How to do it?

Depends upon your mode of thinking

Bricolage approach

Planned approach

36

Problem Solving Methodologies How to do it?

Depends upon your mode of thinking

Bricolage approach

Planned approach

Problem features and aspects are repeatedly tried and manipulated according to your personal way of organizing information

A mistake is not an error, but a correction waiting to be made in the natural course of solving the problem

37

Problem Solving Methodologies How to do it?

Depends upon your mode of thinking

Bricolage approach

Planned approach

Uses logic, formalism, and engineering coupled with a structured methodology

Inherent structure of the planned approach offers makes it easier to show correctness of solution

Dominant method in terms of teaching

38

Tips Find out as much as you can

Reuse what has been done before

Expect future reuse

Break complex problems into subproblems

39

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

40

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

41

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

42

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

43

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