Chapter 12
Programming Concepts
and Languages
© Paradigm Publishing Inc.
12-1
Presentation Overview
•
•
•
•
Programming Concepts
Problem-Solving Techniques
The Evolution of Programming Approaches
Programming Development and
Documentation Tools
• Programming Errors
• The Software Development Life Cycle
• Major Programming Languages
© Paradigm Publishing Inc.
12-2
Programming Concepts
What makes up a programming language?
© Paradigm Publishing Inc.
12-3
Programming Concepts
What makes up a programming language?
– Program – instructions telling a computer how to
perform tasks
© Paradigm Publishing Inc.
12-4
Programming Concepts
What makes up a programming language?
– Program – instructions telling a computer how to
perform tasks
– Programming languages – languages that
communicate with the computer to create programs
© Paradigm Publishing Inc.
12-5
Programming Concepts
What makes up a programming language?
– Program – instructions telling a computer how to
perform tasks
– Programming languages – languages that
communicate with the computer to create programs
– Source code – text files that make up a
programming language
© Paradigm Publishing Inc.
12-6
Programming Concepts
What makes up a programming language?
– Program – instructions telling a computer how to
perform tasks
– Programming languages – languages that
communicate with the computer to create programs
– Source code – text files that make up a
programming language
– Four main computer language programming
elements are variables, executable statements,
looping, and decision statements.
© Paradigm Publishing Inc.
12-7
Programming Concepts
High-Level versus Low-Level Languages
© Paradigm Publishing Inc.
12-8
Programming Concepts
High-Level versus Low-Level Languages
– Low-level language (machine code) is a binary
language consisting of 1s and 0s;
runs faster and takes up less disk space.
© Paradigm Publishing Inc.
12-9
Programming Concepts
High-Level versus Low-Level Languages
– Low-level language (machine code) is a binary
language consisting of 1s and 0s;
runs faster and takes up less disk space.
– High-level language is similar to natural languages,
making it easier to learn and use.
© Paradigm Publishing Inc.
12-10
Programming Concepts
Each
generation
of programs
builds on the
contributions
of the group
of languages
that preceded
it.
© Paradigm Publishing Inc.
12-11
Programming Concepts
Classic Programming Elements
© Paradigm Publishing Inc.
12-12
Programming Concepts
Classic Programming Elements
– Variable – data value stored in computer memory
© Paradigm Publishing Inc.
12-13
Programming Concepts
Classic Programming Elements
– Variable – data value stored in computer memory
– Executable statement –performs an action and
then proceeds to the next statement in sequence
© Paradigm Publishing Inc.
12-14
Programming Concepts
Classic Programming Elements
– Variable – data value stored in computer memory
– Executable statement –performs an action and
then proceeds to the next statement in sequence
– Looping – allows a program to return to a
previously executed instruction and repeat it
© Paradigm Publishing Inc.
12-15
Programming Concepts
Classic Programming Elements
– Variable – data value stored in computer memory
– Executable statement –performs an action and
then proceeds to the next statement in sequence
– Looping – allows a program to return to a
previously executed instruction and repeat it
– Decision statement – point in a program where
different actions may be performed depending on
specific conditions
© Paradigm Publishing Inc.
12-16
Programming
Concepts
Looping allows
a computer
program to
continuously
repeat the same
steps, such as a
program designed
to direct a traffic
light to display
yellow, red, and
green lights at a
consistent rate.
© Paradigm Publishing Inc.
12-17
Programming
Concepts
Using an if-then
statement based
on a particular
action, such as
pushing the
crosswalk button,
a program can
interrupt the
looping pattern,
making the
program more
useful.
© Paradigm Publishing Inc.
12-18
Problem-Solving Techniques
Top-down
design
approach
helps
programmers
break a large
project into
manageable
parts.
Breakdown
process
continues
until there
are no more
steps.
© Paradigm Publishing Inc.
12-19
Problem-Solving Techniques
Problem-Solving Steps
© Paradigm Publishing Inc.
12-20
Problem-Solving Techniques
Problem-Solving Steps
1. Identify the problem.
© Paradigm Publishing Inc.
12-21
Problem-Solving Techniques
Problem-Solving Steps
1. Identify the problem.
2. Analyze the problem.
© Paradigm Publishing Inc.
12-22
Problem-Solving Techniques
Problem-Solving Steps
1. Identify the problem.
2. Analyze the problem.
3. Brainstorm solutions and choose the best one.
© Paradigm Publishing Inc.
12-23
Problem-Solving Techniques
Problem-Solving Steps
1.
2.
3.
4.
Identify the problem.
Analyze the problem.
Brainstorm solutions and choose the best one.
Write the algorithm.
© Paradigm Publishing Inc.
12-24
Problem-Solving Techniques
Problem-Solving Steps
1.
2.
3.
4.
5.
Identify the problem.
Analyze the problem.
Brainstorm solutions and choose the best one.
Write the algorithm.
Prototype the solution.
© Paradigm Publishing Inc.
12-25
Problem-Solving Techniques
Problem-Solving Steps
1.
2.
3.
4.
5.
6.
Identify the problem.
Analyze the problem.
Brainstorm solutions and choose the best one.
Write the algorithm.
Prototype the solution.
Implement and test the solution.
© Paradigm Publishing Inc.
12-26
ProblemSolving
Techniques
Step-by-step
pseudocode
algorithm for
changing a
lightbulb.
© Paradigm Publishing Inc.
12-27
The Evolution of Programming
Approaches
Structured Programming
© Paradigm Publishing Inc.
12-28
The Evolution of Programming
Approaches
Structured Programming
– Creates groups of instructions as independent
elements.
© Paradigm Publishing Inc.
12-29
The Evolution of Programming
Approaches
Structured Programming
– Creates groups of instructions as independent
elements.
– Structured groups of instructions are built on a
routine, which is a section of a program to handle
a function.
© Paradigm Publishing Inc.
12-30
The Evolution of Programming
Approaches
Structured Programming
– Creates groups of instructions as independent
elements.
– Structured groups of instructions are built on a
routine, which is a section of a program to handle
a function.
– A routine is broken down into steps to accomplish
the function.
© Paradigm Publishing Inc.
12-31
The Evolution of Programming
Approaches
Modules
© Paradigm Publishing Inc.
12-32
The Evolution of Programming
Approaches
Modules
– Code modules handle separate components of a
program.
© Paradigm Publishing Inc.
12-33
The Evolution of Programming
Approaches
Modules
– Code modules handle separate components of a
program.
– Each module is a solid portion of a larger structure.
© Paradigm Publishing Inc.
12-34
The Evolution of Programming
Approaches
Modules
– Code modules handle separate components of a
program.
– Each module is a solid portion of a larger structure.
– Modules are reusable, and modularity helps in
tracking down errors.
© Paradigm Publishing Inc.
12-35
The Evolution of Programming
Approaches
Modules
– Code modules handle separate components of a
program.
– Each module is a solid portion of a larger structure.
– Modules are reusable, and modularity helps in
tracking down errors.
– A macro is a recording of steps to perform a
repetitive task.
© Paradigm Publishing Inc.
12-36
The Evolution of Programming
Approaches
Object-Oriented Programming
© Paradigm Publishing Inc.
12-37
The Evolution of Programming
Approaches
Object-Oriented Programming
– Object-oriented programming (OOP) defines
each module (object) with definite rules for
interfacing and a protected set of variables.
© Paradigm Publishing Inc.
12-38
The Evolution of Programming
Approaches
Object-Oriented Programming
– Object-oriented programming (OOP) defines
each module (object) with definite rules for
interfacing and a protected set of variables.
– Protected variables allow a programmer to
prevent data from being altered during program
execution.
© Paradigm Publishing Inc.
12-39
The Evolution of Programming
Approaches
Rapid Application Development
© Paradigm Publishing Inc.
12-40
The Evolution of Programming
Approaches
Rapid Application Development
Rapid application development (RAD) reduces cost
by decreasing time needed to develop a project.
© Paradigm Publishing Inc.
12-41
The Evolution of Programming
Approaches
Rapid Application Development
Rapid application development (RAD) reduces cost
by decreasing time needed to develop a project.
Programmers using RAD follow guidelines
• Use visual development (4GL) tools when possible
• Rapidly prototype new projects
• Approach coding with these priorities
– Use existing code first.
– Buy someone else’s code second.
– Write new code last.
© Paradigm Publishing Inc.
12-42
Programming Development
and Documentation Tools
Compilers and Interpreters
© Paradigm Publishing Inc.
12-43
Programming Development
and Documentation Tools
Compilers and Interpreters
– Compiler – program that translates programming
language source code into machine code
© Paradigm Publishing Inc.
12-44
Programming Development
and Documentation Tools
Compilers and Interpreters
– Compiler – program that translates programming
language source code into machine code
– Interpreter – translates instructions one-by-one as
source code is being executed; identifies errors as
they are encountered, including the line containing
the error
© Paradigm Publishing Inc.
12-45
Programming Development
and Documentation Tools
Debuggers
© Paradigm Publishing Inc.
12-46
Programming Development
and Documentation Tools
Debuggers
– Debugger – a software tool that helps programmers
find errors quickly.
© Paradigm Publishing Inc.
12-47
Programming Development
and Documentation Tools
Debuggers
– Debugger – a software tool that helps programmers
find errors quickly.
– Allows programmers to examine closely what is
happening when a program runs.
© Paradigm Publishing Inc.
12-48
Programming Development
and Documentation Tools
Debuggers
– Debugger – a software tool that helps programmers
find errors quickly.
– Allows programmers to examine closely what is
happening when a program runs.
– Usually an integral component of compilers and
interpreters.
© Paradigm Publishing Inc.
12-49
Programming Development
and Documentation Tools
Document Tools
© Paradigm Publishing Inc.
12-50
Programming Development
and Documentation Tools
Document Tools
– Flowchart – provides a visual diagram of an
algorithm
© Paradigm Publishing Inc.
12-51
Programming Development
and Documentation Tools
Document Tools
– Flowchart – provides a visual diagram of an
algorithm
– CASE tools – help programming team schedule and
coordinate its operations
© Paradigm Publishing Inc.
12-52
Programming Development
and Documentation Tools
Document Tools
– Flowchart – provides a visual diagram of an
algorithm
– CASE tools – help programming team schedule and
coordinate its operations
– Comment – informal message inserted into a
program usually to explain source code to later users
© Paradigm Publishing Inc.
12-53
Programming
Development
and
Documentation
Tools
These symbols
are used in
flowcharts to
represent the
logic of a
program.
© Paradigm Publishing Inc.
12-54
Programming
Development
and
Documentation
Tools
Flowcharts help
programmers
visualize the steps
in a software
program.
© Paradigm Publishing Inc.
12-55
Programming Development and
Documentation Tools
Flowcharts help programmers visualize the steps in a software
program.
© Paradigm Publishing Inc.
12-56
Programming Errors
What programming errors are in programs?
© Paradigm Publishing Inc.
12-57
Programming Errors
What programming errors are in programs?
– Syntax errors – typing errors or misunderstanding of
rules of the language
© Paradigm Publishing Inc.
12-58
Programming Errors
What programming errors are in programs?
– Syntax errors – typing errors or misunderstanding of
rules of the language
– Logic errors – program instructs computer to
perform an action incorrectly
© Paradigm Publishing Inc.
12-59
Programming Errors
What programming errors are in programs?
– Syntax errors – typing errors or misunderstanding of
rules of the language
– Logic errors – program instructs computer to
perform an action incorrectly
– Run-time errors – mistakes that occur when an
application is running (crash or infinite loop)
© Paradigm Publishing Inc.
12-60
Programming Errors
What programming errors are in programs?
– Syntax errors – typing errors or misunderstanding of
rules of the language
– Logic errors – program instructs computer to
perform an action incorrectly
– Run-time errors – mistakes that occur when an
application is running (crash or infinite loop)
– Style errors – poorly written programming code that
may cause dissatisfaction with program
© Paradigm Publishing Inc.
12-61
The Software Development
Life Cycle
What are the steps in the software development
life
cycle?
The software development life cycle involves planning, designing,
implementing, testing, and release of application software.
© Paradigm Publishing Inc.
12-62
Major Programming Languages
Commonly used programming languages
© Paradigm Publishing Inc.
12-63
Major Programming Languages
Machine Code
© Paradigm Publishing Inc.
12-64
Major Programming Languages
Machine Code
– programming language that computers actually read
and interpret
© Paradigm Publishing Inc.
12-65
Major Programming Languages
Machine Code
– programming language that computers actually read
and interpret
– machine code written in a binary string of 1s and 0s
© Paradigm Publishing Inc.
12-66
Major Programming Languages
Machine Code
– programming language that computers actually read
and interpret
– machine code written in a binary string of 1s and 0s
– difficult to memorize the long binary strings that
comprise the machine code
© Paradigm Publishing Inc.
12-67
Major Programming Languages
Assembly Language
© Paradigm Publishing Inc.
12-68
Major Programming Languages
Assembly Language
– uses symbols and words to represent elements of
machine code
© Paradigm Publishing Inc.
12-69
Major Programming Languages
Assembly Language
– uses symbols and words to represent elements of
machine code
– must be converted to machine code by a compiler
© Paradigm Publishing Inc.
12-70
Major Programming Languages
Assembly Language
– uses symbols and words to represent elements of
machine code
– must be converted to machine code by a compiler
– runs fastest and uses least memory
© Paradigm Publishing Inc.
12-71
Major Programming Languages
Assembly Language
– uses symbols and words to represent elements of
machine code
– must be converted to machine code by a compiler
– runs fastest and uses least memory
– programs are difficult to write and development times
are lengthened
© Paradigm Publishing Inc.
12-72
Major Programming Languages
COBOL
© Paradigm Publishing Inc.
12-73
Major Programming Languages
COBOL
– used chiefly for business applications by large
institutions and companies
© Paradigm Publishing Inc.
12-74
Major Programming Languages
COBOL
– used chiefly for business applications by large
institutions and companies
– is slow and cumbersome language, but has large body
of existing code and many programmers know the
language
© Paradigm Publishing Inc.
12-75
Major Programming Languages
RPG
© Paradigm Publishing Inc.
12-76
Major Programming Languages
RPG
– commonly used in business environments
© Paradigm Publishing Inc.
12-77
Major Programming Languages
RPG
– commonly used in business environments
– inefficient, but simplifies coding of database
applications
© Paradigm Publishing Inc.
12-78
Major Programming Languages
RPG
– commonly used in business environments
– inefficient, but simplifies coding of database
applications
– is familiar to many programmers
© Paradigm Publishing Inc.
12-79
Major Programming Languages
RPG
– commonly used in business environments
– inefficient, but simplifies coding of database
applications
– is familiar to many programmers
– often used on midrange and mainframe computers
© Paradigm Publishing Inc.
12-80
Major Programming Languages
FORTRAN
© Paradigm Publishing Inc.
12-81
Major Programming Languages
FORTRAN
– for many years, the language of choice for math,
science, and engineering projects
© Paradigm Publishing Inc.
12-82
Major Programming Languages
FORTRAN
– for many years, the language of choice for math,
science, and engineering projects
– still in use today in factories and laboratories
© Paradigm Publishing Inc.
12-83
Major Programming Languages
BASIC
© Paradigm Publishing Inc.
12-84
Major Programming Languages
BASIC
– high-level language that is friendlier and more natural
than COBOL or FORTRAN
© Paradigm Publishing Inc.
12-85
Major Programming Languages
BASIC
– high-level language that is friendlier and more natural
than COBOL or FORTRAN
– runs slowly, but faster to develop for programmers
© Paradigm Publishing Inc.
12-86
Major Programming Languages
BASIC
– high-level language that is friendlier and more natural
than COBOL or FORTRAN.
– runs slowly, but faster to develop for programmers.
This sequence of code will print the numbers 1 to 10.
© Paradigm Publishing Inc.
12-87
Major Programming Languages
Visual Basic (VB)
© Paradigm Publishing Inc.
12-88
Major Programming Languages
Visual Basic (VB)
– language of choice for developing software
prototypes or for developing interfaces for Windows
platforms
© Paradigm Publishing Inc.
12-89
Major Programming Languages
Visual Basic (VB)
– language of choice for developing software
prototypes or for developing interfaces for Windows
platforms
– quick and easy to develop, but run slowly and is
demanding of RAM and disk space
© Paradigm Publishing Inc.
12-90
Major Programming Languages
Visual Basic (VB)
– language of choice for developing software
prototypes or for developing interfaces for Windows
platforms
– quick and easy to develop, but run slowly and is
demanding of RAM and disk space
– supports graphic interfaces
© Paradigm Publishing Inc.
12-91
Major Programming Languages
C
© Paradigm Publishing Inc.
12-92
Major Programming Languages
C
– compromise between high-level and low-level
languages, containing components of BASIC and
assembly language
© Paradigm Publishing Inc.
12-93
Major Programming Languages
C
– compromise between high-level and low-level
languages, containing components of BASIC and
assembly language
– not as easy to read as BASIC, but runs considerably
faster and uses less space
© Paradigm Publishing Inc.
12-94
Major Programming Languages
C++
© Paradigm Publishing Inc.
12-95
Major Programming Languages
C++
– superset of C; any C program should run in C++
© Paradigm Publishing Inc.
12-96
Major Programming Languages
C++
– superset of C; any C program should run in C++
– added features such as object-oriented programming
© Paradigm Publishing Inc.
12-97
Major Programming Languages
C++
– superset of C; any C program should run in C++.
– added features such as object-oriented programming.
This sequence of code will print the numbers 1 to 10.
© Paradigm Publishing Inc.
12-98
Major Programming Languages
C#
© Paradigm Publishing Inc.
12-99
Major Programming Languages
C#
– modern object-oriented language derived from C++
and Java
© Paradigm Publishing Inc.
12-100
Major Programming Languages
C#
– modern object-oriented language derived from C++
and Java
– combines productivity of Visual Basic with power of
C++
© Paradigm Publishing Inc.
12-101
Major Programming Languages
C#
– modern object-oriented language derived from C++
and Java
– combines productivity of Visual Basic with power of
C++
– allows use of features in Microsoft.NET framework,
C, and Microsoft’s Component Object Model (COM)
© Paradigm Publishing Inc.
12-102
Major Programming Languages
Scripting Languages
© Paradigm Publishing Inc.
12-103
Major Programming Languages
Scripting Languages
– interpreted language that is relatively easy to learn and
use
© Paradigm Publishing Inc.
12-104
Major Programming Languages
Scripting Languages
– interpreted language that is relatively easy to learn and
use
– explains what a computer should do in English-like
terms but not precisely how the computer should do it
© Paradigm Publishing Inc.
12-105
Major Programming Languages
Scripting Languages
– interpreted language that is relatively easy to learn and
use
– explains what a computer should do in English-like
terms but not precisely how the computer should do it
– Hypertext Markup Language (HTML), JavaScript,
VBScript, and perl are scripting languages
© Paradigm Publishing Inc.
12-106
Major
Programming
Languages
This sequence
of code directs
a browser to
display buttons
users can click
to change the
background
color within
the Web
browser
window.
© Paradigm Publishing Inc.
12-107
Major Programming Languages
DHTML
© Paradigm Publishing Inc.
12-108
Major Programming Languages
DHTML
– allows Web page designers to alter contents of Web
page screen dynamically
© Paradigm Publishing Inc.
12-109
Major Programming Languages
DHTML
– allows Web page designers to alter contents of Web
page screen dynamically
– allows viewer actions to change contents of a Web page
© Paradigm Publishing Inc.
12-110
Major Programming Languages
DHTML
– allows Web page designers to alter contents of Web
page screen dynamically
– allows viewer actions to change contents of a Web page
– displays faster than HTML
© Paradigm Publishing Inc.
12-111
Major Programming Languages
DHTML
– allows Web page designers to alter contents of Web
page screen dynamically
– allows viewer actions to change contents of a Web page
– displays faster than HTML
– higher quality appearance and more graphically
responsive to user actions
© Paradigm Publishing Inc.
12-112
Major Programming Languages
XHTML
© Paradigm Publishing Inc.
12-113
Major Programming Languages
XHTML
– allows Web pages to separate their content from the
format supported by a Web page
© Paradigm Publishing Inc.
12-114
Major Programming Languages
XHTML
– allows Web pages to separate their content from the
format supported by a Web page
– screens with different sizes and resolutions can display
the same Web page content without the Web designer
having to write specialized versions for each
© Paradigm Publishing Inc.
12-115
Major Programming Languages
Wireless Markup Language (WML)
© Paradigm Publishing Inc.
12-116
Major Programming Languages
Wireless Markup Language (WML)
– created specifically for small systems such as cell
phones and handheld computers
© Paradigm Publishing Inc.
12-117
Major Programming Languages
Wireless Markup Language (WML)
– created specifically for small systems such as cell
phones and handheld computers
– allows designers to build pages that work for small
screens with limited display and input capabilities
© Paradigm Publishing Inc.
12-118
On the Horizon
Based on the information presented in this
chapter and your own experience, what do you
think is on the horizon?
© Paradigm Publishing Inc.
12-119
Descargar

Computers: Understanding Technology, 3e