Chapter 1 - PowerPoint PPT Presentation

About This Presentation
Title:

Chapter 1

Description:

Chapter 1 Intro to Computing 1.1 Types of Languages and Why They Are Useful Computers require a method of instruction to operate. Modern computers get their ... – PowerPoint PPT presentation

Number of Views:126
Avg rating:3.0/5.0
Slides: 23
Provided by: vzay4
Learn more at: http://www.cs.ucr.edu
Category:

less

Transcript and Presenter's Notes

Title: Chapter 1


1
Chapter 1 Intro to Computing
  • 1.1 Types of Languages and Why They Are Useful
  • Computers require a method of instruction to
    operate. Modern computers get their instructions
    from programming languages.
  • A programming language is an agreed-upon format
    of symbols that enables a programmer to instruct
    a computer to perform certain predefined tasks.
  • There are two types of languages depending on how
    understandable they are high- and low-level
    languages.

2
Chapter 1 Intro to Computing
  • The Development of Programming Languages
  • Manual switches using binary numbers
  • Assembly language and punch cards two early
    breakthroughs
  • COBOL and FORTRAN allowed programs to be run on
    another system than the original
  • PL/1 result of one of the quests for a single
    universal language for all needs
  • C originally used for developing operating
    systems, but became very popular
  • C and other object-oriented languages enabled
    creation of reusable programs
  • Java like C, but can be run on any computer
    without recompiling

3
Chapter 1 Intro to Computing
  • 1.2 Where Does Visual Basic .NET Fit In?
  • Visual Basic .NET has its roots in a language
    called BASIC which was
  • Developed in 1964 to help nonscientists develop
    computer programs
  • Quite limited in functionality
  • Difficult to use for large, integrated systems

4
Chapter 1 Intro to Computing
  • Features of Visual Basic .NET
  • Visual Basic .NET is quite different from the
    original BASIC
  • Complete development enivronment
  • Primarily meant for developing prototypes and
    front ends for database applications.
  • Truly object-oriented
  • Part of the larger world of the .NET framework,
    which provides the same development environment
    and contains the same object model. It is fairly
    easy to switch between different languages within
    the framework. Objects developed in any of the
    .NET languages can be accessed in the others.

5
Chapter 1 Intro to Computing
  • 1.3 What Makes a Quality Program?
  • A quality program should have all of the
    following characteristics
  • Readability
  • Modularity
  • Efficiency
  • Robustness
  • Usability

6
Chapter 1 Intro to Computing
  • Readability
  • It is imperative that the program be written so
    that other programmers as well as the original
    programmer can understand it since the
    maintenance phase of a computer project can
    actually be more expensive than the original
    development process.
  • A key method a programmer can employ is to add
    comments to the program which explain the
    programs purpose and any unclear pieces of code.
  • It is also often necessary to produce external
    documentation.
  • A programmer who can produce readable, reliable
    code is valuable to a company and is less likely
    to get stuck with maintaining cryptic code.
  • Programming standards/conventions are very
    important, especially when a group of programmers
    work together.

7
Chapter 1 Intro to Computing
  • Modularity
  • Programs should be written in an orderly fashion
    with problems divided into smaller subproblems
    and then assembled in a logical order.

8
Chapter 1 Intro to Computing
  • Efficiency
  • Visual Basic .NET is not usually used when high
    performance is the key design criteria.
  • Program size of the program itself is usually not
    an issue due to declining computer memory prices
    and the large size of the .NET framework itself.
  • If you are improving efficiency of your VB .NET
    application, you are most likely adding
    complexity without adding value to the
    application.
  • If you do decide to add cryptic lines for the
    purposes of speed and/or size, make sure to
    document them and include a simpler way for
    others to easier understand your code.

9
Chapter 1 Intro to Computing
  • Robustness
  • A program should gracefully handle cases when
    the input to it is not as expected or some other
    error has occurred. A program should never crash.

10
Chapter 1 Intro to Computing
  • Usability
  • A program must meet the needs of the end user,
    i.e. be correct, in order to be useful.

11
Chapter 1 Intro to Computing
1.4 Understanding Algorithms An algorithm is a
detailed sequence of steps required to solve a
problem. Algorithms can be represented in a
graphical format called a flowchart. Flowcharts
can be large, but they are often useful.
Used to represent calculations and data
manipulation.
Used to represent a comparison with either a
Yes/True result or a No/False result.
Used to represent the input or output of data.
Used to indicate the beginning or ending of a
task.
These connector lines are used to join the other
symbols within the flowchart. The second and
third ones are used in conjunction with a
Decision Box.
12
Chapter 1 Intro to Computing
An Example Algorithm Step 1 Turn the stereo
on. Step 2 If the band is set to FM, switch it
to AM. Step 3 If the station is set to a station
greater than 610, turn the station to the left
until 610 is reached. Step 4 If the station is
set to a station less than 610, turn the station
to the right until 610 is reached. Step 5 Listen
to the best sports talk station in the country.
13
Chapter 1 Intro to Computing
The flowchart of the example algorithm
14
Chapter 1 Intro to Computing
  • 1.5 Top-Down Versus Even-Driven Algorithms
  • Top-down or sequential problems are solved by
    traditional programming languages.
  • They lend themselves to problems that have a
    starting point, a predetermined series of steps,
    and an ending point.
  • Algorithms that respond to external stimuli like
    clicking a mouse or selecting an item from a
    pull-down menu are considered event-driven.

15
Chapter 1 Intro to Computing
Consider the steps required to boil an egg. Step
1 Open closet door. Step 2 Remove pot. Step
3 Close closet door. Step 4 Place pot under
sink faucet. Step 5 Turn on the cold water. Step
6 Wait until the pot is ¾ full. Step 7 Turn off
the cold water. Step 8 Place pot on stove
burner. Step 9 Turn burner on high heat. Step
10 Open refrigerator door. Step 11 Take out the
egg carton. Step 12 Open the egg carton. Step
13 Remove an egg from the carton.
Step 14 Close the egg carton. Step 15 Place the
egg carton back in the refrigerator. Step
16 Close refrigerator door. Step 17 Open the
silverware drawer. Step 18 Remove a large
spoon. Step 19 Close the silverware drawer. Step
20 Wait until the water is boiling. Step
21 When the water is boiling, use the spoon to
place the egg in the pot. Step 22 Wait three
minutes until the egg is cooked. Step 23 Shut
off the stove burner. Step 24 Remove the egg
from the pot.
16
Chapter 1 Intro to Computing
Event-Driven Algorithms Consider the steps
required for playing tennis (for simplicitys
sake, lets assume that you are the one serving).
Step 1 Walk up to the serving line. Step
2 Toss ball up in the air. Step 3 Swing the
racket so that you hit the ball to the other
player in the opposite box. Step 4 Wait for the
ball to strike the tennis court. Step 5A If the
ball lands legally in the box, wait to see if the
opponent hits your serve back toward you. Step
5B If the ball lands outside the box, you must
serve again. Go to Step 1. Step 6A If the ball
is hit back and it is hit to your right, move
toward the right so you are in position to hit it
back. Step 6B If the ball is hit back and it is
hit to your left, move toward the left so you are
in position to hit it back. Step 6C If the ball
is hit back and it is hit directly at you, wait
for it to arrive. Step 7A If the ball is hit
back and it is hit in front of you, move
forward. Step 7B If the ball is hit back and it
is hit behind you, move backward. Step 8A If the
ball is hit outside the lines, do not hit it but
let it pass. Serve again by going to Step 1.
17
Chapter 1 Intro to Computing
  • 1.6 Concept of an Object
  • Drill 1.4 Describe in detail the properties of a
    simple household phone and the actions that can
    be performed upon it.
  • Properties
  • 1. Button with the number 1 on it.
  • 2. Button with the number 2 and the letters ABC
    on it.
  • 3. Button with the number 3 and the letters DEF
    on it.
  • 4. Button with the number 4 and the letters GHI
    on it.
  • 5. Button with the number 5 and the letters JKL
    on it.
  • 6. Button with the number 6 and the letters MNO
    on it.
  • 7. Button with the number 7 and the letters PQRS
    on it.
  • 8. Button with the number 8 and the letters TUV
    on it.
  • 9. Button with the number 9 and the letters WXYZ
    on it.
  • 10. Button with the number 0 on it.
  • 11. Button with an on it.
  • 12. Button with a on it.
  • 13. Button with the word REDIAL on it.
  • 14. Large button with no wording on it.

18
Chapter 1 Intro to Computing
  • 1.6 Concept of an Object
  • Describe in detail the properties of a simple
    household phone and the actions that can be
    performed upon it.
  • Behaviors
  • Button 1 If pushed, it enters the 1 digit of a
    phone number.
  • Button 2 If pushed, it enters the 2 digit of a
    phone number.
  • Button 3 If pushed, it enters the 3 digit of a
    phone number.
  • Button 4 If pushed, it enters the 4 digit of a
    phone number.
  • Button 5 If pushed, it enters the 5 digit of a
    phone number.
  • Button 6 If pushed, it enters the 6 digit of a
    phone number.
  • Button 7 If pushed, it enters the 7 digit of a
    phone number.
  • Button 8 If pushed, it enters the 8 digit of a
    phone number.
  • Button 9 If pushed, it enters the 9 digit of a
    phone number.
  • Button 0 If pushed, it enters the 0 digit of a
    phone number.
  • Button Used to interact with computer systems
    that the phone may connect to.
  • Button Used to interact with computer systems
    that the phone may connect to.
  • REDIAL Button If pushed, it dials the last phone
    number entered into the phone.
  • Large Button This hangs up the phone, which ends
    the phone call and resets the phone.

19
Chapter 1 Intro to Computing
  • 1.6 Concept of an Object
  • Describe in detail the properties of a simple
    digital alarm clock and the actions that can be
    performed upon it.
  • Properties
  • 1. Hour Display An LCD output to display the
    hour of the time being displayed. It can be a
    number from 1 to 12.
  • 2. Minute Display An LCD output to display the
    current minute of the time being displayed. It
    can be a number from 0 to 59.
  • 3. Second Display An LCD output to display the
    current second of the time being displayed. It
    can be a number from 0 to 59.
  • 4. A.M./P.M. Display An LCD output to display an
    indicator of whether the current time is in the
    A.M. or P.M. for the time being displayed.
  • 5. Current Hour The hour of the current time. It
    can be a number from 1 to 12.
  • 6. Current Minute The minute of the current
    time. It can be a number from 0 to 59.
  • 7. Current Second The second of the current
    time. It can be a number from 0 to 59.
  • 8. Current A.M./P.M. An indicator of whether the
    current time is in the A.M. or P.M.
  • 9. Alarm Hour The hour of the time the alarm
    will go off if it is set to go off. It can be a
    number from 1 to 12.
  • 10. Alarm Minute The minute of the time the
    alarm will go off if it is set to go off. It can
    be a number from 0 to 59.

20
Chapter 1 Intro to Computing
  • 1.6 Concept of an Object
  • Describe in detail the properties of a simple
    digital alarm clock and the actions that can be
    performed upon it.
  • Properties (continued)
  • 11. Alarm Second The second of the time the
    alarm will go off if it is set to go off. It can
    be a number from 0 to 59.
  • 12. Alarm A.M./P.M. An indicator of whether the
    alarm will go off in the A.M. or P.M., if the
    alarm is set.
  • Behaviors
  • 1. Set Alarm Set the hour, minute, and A.M./P.M.
    of the alarm.
  • 2. Set Time Set the hour, minute, and A.M./P.M.
    of the actual time.
  • 3. Fast Button If the switch is in either Set
    Alarm or Set Time position, increment the Alarm
    Time or Actual Time at a fast pace. As long as
    the button is depressed, the time will continue
    to increment.
  • 4. Slow Button If the switch is in either Set
    Alarm or Set Time position, increment the Alarm
    Time or Actual Time at a slow pace. As long as
    the button is depressed, the time will continue
    to increment.
  • 5. Activate Alarm If the button is pressed, the
    alarm is set to go off at the time indicated by
    the Alarm Time.

21
Chapter 1 Intro to Computing
  • 1.6 Concept of an Object
  • Describe in detail the properties of a simple
    digital alarm clock and the actions that can be
    performed upon it.
  • Behaviors (continued)
  • 6. Deactivate Alarm If the button is pressed and
    the alarm is on, shut it off.
  • 7. Increment Time The clock will automatically
    increment the time by a second every second and
    display it. If the new time is equal to the Alarm
    Time and the alarm is set to go on, then the
    alarm will sound.

22
Chapter 1 Intro to Computing
  • 1.7 Interpreters, Compilers, and JITs
  • High-level languages like Visual Basic .NET must
    be converted into a language the machine
    understands before it can execute it. There are
    three main methods for accomplishing this task
  • Interpreting. An interpreter is a program that
    converts the language at the time the application
    is executed. This leads to slow executing
    applications.
  • Compiling. A compiler will perform all of the
    translation at once and store the results in a
    file called an executable. This results in a
    faster execution but one which is compiled for a
    specific computer chip.
  • Just-in-time compiling (JIT). JIT compilers
    compile the source code into an intermediate
    language which is then translated just in time to
    be executed by the computer. Visual Basic .NET
    and Java use this method.
Write a Comment
User Comments (0)
About PowerShow.com