Quiz About [Your topic]

advertisement
CS 101-E: Introduction
Aaron Bloomfield
MEC 205
MEC 215
Clark G004 (really)
1
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)
2
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
3
A bit of humor: Review of last time
4
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)
5
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?
6
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
Detailed
Program
knowledge
to which of
computer
the
machine
respond
is not
Java
Symbolic
is acan
high-level
language
For
program
to be
directly.
required.
Each machine
Uses
instruction
a
for
programming
coding
executed
itcode
must
be
is
a
vocabulary
binary
and
that
language
language
instructions
translated
structure
corresponds
closer to
to7athe
problem
native being
instruction
solved
A bit of humor: Input methods
8
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
9
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
10
Task
 Display the forecast
I think there is a world market for maybe five computers.
Thomas Watson, IBM, 1943.
11
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.");
}
}
Anmethod
Three
A
application
statements
is a named
program
make
piece
is
uprequired
the
of code
action
to
that
have
of performs
method
a
main()action
some
public
static void
or implements
method named
a behavior
main().
Method main() is part of class DisplayForecast12
Sample output
13
Java Documentation
 Familiarize yourself with the Java documentation
 It will save you lots of time!
14
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.");
}
}
15
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.
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
While at NCR, he was convicted for illegal anticompetitive 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.
//
//
//
//
//
//
//
//
//
//
//
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: public class DisplayForecast {
"I think there is a world market for maybe five computers"
there is no evidence he ever made it. The author Kevin
// method main(): application entry point
Maney tried to find the origin of the quote. He has been
public static void main(String[] args) {
unable to locate any speeches or documents of Watson's
System.out.print("I think there is a world market for
that contain this, nor is it present in any contemporary
System.out.println(" maybe five computers.");
articles about IBM. The earliest known citation is from
System.out.println("
Thomas Watson, IBM, 1943.");
1986 on Usenet in the signature of a poster from Convex
}
Computer Corporation as "I think there is a world market }
16
for about five computers" --Remark attributed to Thomas
J. Watson (Chairman of the Board of International
Java and the Internet
Your machine
Your friend's machine
I think ...
DisplayForecast.java
Java
Compiler
JVM
DisplayForecast.class
DisplayForecast.class
Modem
Modem
Internet
17
Engineering software
 Complexity of software grows as attempts are made to make
it easier to use
 Rise of wizards
18
Software engineering
 Goal
 Production of software that is effective and reliable,
understandable, cost effective, adaptable, and reusable
 Design
Makes
Work
Because
Cost
to
correctly
sense
software
develop
of the
due
and
long
and
so
tonot
that
the
lifetime
maintain
fail
great
new many
features
should
costspeople
involved
not
andexceed
will
capabilities
tobehave
involved
expected
can
flexible
be added
components
benefit
that can be used in other software
 Creation
 Debugging
 Maintenance
 Enhancement
 Two-thirds of the cost is typically beyond creation
19
Principles of software engineering
 Abstraction
 Encapsulation
 Modularity
Ranking
Separate
Construct
Determine
or ordering
components
a the
system
relevant
of from
objects
into
properties
externaland
and
andpackages
internal
features
components
while ignoring
aspects
nonessential
details
 Hierarchy
20
A bit of humor:
1989 Computer
Advertisement
Guess the price!
21
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
22
Programming
 Class
 Term for a type of software object
 Object
 An instance of a class with
 specific properties and
attributes
23
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
24
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
25
Problem Solving
 Why care about computerbased problem
solving (i.e., programming)?





Neat
Frontier of science
Profitable
Necessary
Quality of life
26
Problem Solving
 Remember
Accept
Solutions
 The
Thegoal
Often
process
require
is notisboth
aiterative
clever
concrete
solution
andbut
abstract
a correct
thinking
solution
 Teamwork
In solving the problem increased understanding might
require restarting
27
Problem Solving Process
 What is it?
28
Problem Solving Process
 What is it?
 Analysis
 Design
 Implementation
 Testing
29
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
30
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
31
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
32
Problem Solving Process
 What is it?
 Analysis
 Design
 Implementation
 Testing
Test the components individually and collectively
33
Problem Solving Process
Determine
problem features
Describe objects
and methods
Produce the
classes and code
Examine for
correctness
Analysis
Rethink as
appropriate
Design
Implementation
Testing
34
Problem Solving Methodologies
 How to do it?
 Depends upon your mode of thinking
 Bricolage approach
 Planned approach
35
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
36
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
37
Tips
 Find out as much as you can
 Reuse what has been done before
 Expect future reuse
 Break complex problems into subproblems
38
Tips
 Find out as much as you can
 Reuse what has been done before
 Expect future reuse
 Break complex problems into subproblems
Consider
Research
can is
require
and generate questions
Find out what
knownsignificant
about thetime
problem
Sketching
apresenter
solution
andbecause
then repeatedly
its components
The
worthwhile
the resultrefine
is a better
Talk effort
to theis
until
the entire process is specified
understanding
Determine what attempts have succeeded and what attempts
True
of the problem makes it easier to solve
have understanding
failed
39
Tips
 Find out as much as you can
 Reuse what has been done before
 Expect future reuse
 Break complex problems into subproblems
Your
Be
open
timetoisindirect
valuable
use of existing materials
Correctness is probably even more valuable
Use existing infrastructure that is known to work
40
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
41
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
42
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
43
Download