![Page 1: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/1.jpg)
1
Technology in Action
Chapter 7
Behind the Scenes: Software Programming
![Page 2: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/2.jpg)
2
Chapter Topics Life cycle of a program Problem statement Algorithms Moving from algorithm to code Moving from code to machine language Testing programs Completing a program Selecting the right programming language Most popular programming languages
![Page 3: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/3.jpg)
3
Computer Programming and Software Engineering
The instructions that make up a computer program are sometimes referred to as code
Programs can have millions of lines of code Developed by computer programmers
![Page 4: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/4.jpg)
4
![Page 5: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/5.jpg)
5
Programming Languages
Programming languages are made up of keywords and grammar rules designed for creating computer instructions
Low-level languages typically include commands specific to a particular CPU or microprocessor family
High-level languages use command words and grammar based on human languages
![Page 6: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/6.jpg)
6
The Life Cycle of a Program Programming is the process of translating a
task into a series of commands a computer will use to perform that task
Programming involves: Identifying the parts of a task the computer can
perform Describing tasks in a specific and complete
manner Translating the tasks into a language that is
understood by the computer’s CPU
![Page 7: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/7.jpg)
7
Program Development Life Cycle
Step 5Finishing the Project
Step 4Debugging
Step 3Coding
Step 2Making a Plan
Step 1Describing the Problem
![Page 8: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/8.jpg)
8
Step 1 : Describing the Problem
The problem statement is: The starting point of programming A description of tasks the program is to accomplish How the program will execute the tasks Created through interaction between the programmer and
the user
The program statement includes error handling and a testing plan
![Page 9: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/9.jpg)
9
PROGRAM GOAL: To compute the total pay for a fixed number of hours worked at a parking garage.
INPUTS: Number of Hours Worked........................ a positive number
OUTPUTS: Total Pay Earned ................................... a positive number
PROCESS: The Total Pay Earned is computed as $7.32 per hour for the first eight hours worked each day. Any hours worked beyond the first eight are billed at $11.73 per hour.
ERROR HANDLING:
The input Number of Hours Worked must be a positive real number. If it is a negative number or other nonacceptable character, the program will force the user to reenter the information.
TESTING PLAN: INPUT OUTPUT NOTES
8 8*7.32 Testing positive input
3 3*7.32 Testing positive input
12 8*7.32 + 4*11.73 Testing overtime input
–6 Error message/ask user to reenter value
Handling error
Parking Garage Example
![Page 10: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/10.jpg)
10
Step 2: Developing an Algorithm
Algorithm development: A set of specific, sequential steps
that describe what the computer program must do
Complex algorithms include decision points: Binary (yes/no) Loop (repeating actions)
Visual tools used to track algorithm and decision points:
Head off to cafe
Buy textbook
Go to accounting
lecture
Yes No
No
No
Yes
Yes
Wake Up
Check wallet for $
Do I have > $80
Go get gas
Did I get $80 from the ATM?
Do I have my credit card?
Go to the ATM for cash
![Page 11: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/11.jpg)
11
Flowchart and Pseudocode
Underlined words are information items that appear repeatedly in the algorithm.
1. Ask the user how many hours they worked today2. If the number of hours worked < = 8, compute total pay without overtime otherwise, compute total pay with overtime pay3. Print total pay
Bold terms show actions that are common in programming, such as reading data, making decisions, printing, and so on.
Flowchart Pseudocode
![Page 12: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/12.jpg)
12
Top-Down Design Problem is divided into a series of high-level tasks Detailed subtasks are created from high-level tasks
![Page 13: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/13.jpg)
13
Object-Oriented Analysis Object-oriented analysis Classes (categories of
inputs) are identified Classes are defined by
information (data) and actions (methods or behaviors)
Objects are defined by their class, data, and behavior
Interaction between classes is determined
Existing classes can be used for other projects
![Page 14: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/14.jpg)
14
Step 3: Coding Coding is translating an algorithm into a
programming language Generations of programming languages
increasing in demands on machines DEcreasing in demands on humans
![Page 15: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/15.jpg)
15
Programming Languages
First-generation languages Machine language (1's and 0's) Bits describe the commands (1011 0101)
Second-generation languages Assembly languages Words describe the commands ADD X, Y or MOV Y, 13 need a translator - an assembler program
![Page 16: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/16.jpg)
16
Programming Languages Third-generation languages
FORTRAN, BASIC, C, JAVA use symbols to describe commands TotalPay = Hours * Rate; More abstract, more like the way humans think
Fourth-generation languages SQL More power built into the language, human has to make
only a few choices - wizards, scripts uses sentences to describe commands Select all where State = KY and Rate > 5
![Page 17: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/17.jpg)
17
Programming Languages
Fifth-generation languages Hypothetical based on natural (human) languages
![Page 18: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/18.jpg)
18
Compilation
Compilation is the process of converting code into machine language
Compiler reads the source code and translates it into machine language
After compilation, programmers have an executable program
![Page 19: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/19.jpg)
19
Step 4: Debugging Running a program to find and fix errors is
known as debugging Debugger: Tool that helps programmers
locate logical errors Syntax vs. Semantics
![Page 20: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/20.jpg)
20
Syntax and Semantics
Syntax – the rules of a language - how statements are formed - punctuation, spelling, etc.
Semantics – the meaning of something said in that language - what does the computer do when that statement is executed?
![Page 21: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/21.jpg)
21
Step 5: Finishing the Project Users test the program (internal testing) Beta version released:
Information collected about errors before final revision
Software updates (service packs): Problems found after commercial release
Documentation created: User manuals User training
![Page 22: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/22.jpg)
22
Program Planning
Problem statement:
Givens:
two pizzas to compare
both pizzas contain the same toppings
the pizzas could be round or square
the prices, shapes, and sizes of the two pizzas
Result:
a message indicating which pizza has the lower price per square inch
![Page 23: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/23.jpg)
23
Program Coding
A program editor is a type of text editor specially designed for entering code for computer programs
![Page 24: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/24.jpg)
24
Program Coding
A IDE (integrated development environment) provides programmers with tools to build substantial sections of a program Form design grid Editor Compiler Linker Execution Debugger
![Page 25: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/25.jpg)
25
Program Testing
A computer program must be tested to ensure that it works correctly
Program errors include Syntax errors Logic errors (semantics) Runtime errors
A debugger can help a programmer read through lines of code and solve problems
![Page 26: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/26.jpg)
26
Program Documentation
Remarks or “comments” are a form of documentation that programmers insert into the program code
![Page 27: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/27.jpg)
27
Algorithms
Set of steps for carrying out a task that can be written down and implemented
Start by recording the steps you take to solve the problem manually
Specify how to manipulate information Specify what the algorithm should display as
a solution
![Page 28: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/28.jpg)
28
Expressing an Algorithm
Pseudocode If Shape1 is round then
squareinches1 is pi * (size1 / 2) squared otherwise
squareinches1 is size1 * size1 set SqInchPrice1 to Price1 / Squareinches1 while there are more pizzas
get their datacalculate SquareInchPrices
![Page 29: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/29.jpg)
29
Expressing an Algorithm
Flowchart
The pizza program flowchartillustrates how the computershould proceed through theinstructions in the final program.
CLICK TO START
![Page 30: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/30.jpg)
30
![Page 31: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/31.jpg)
31
Expressing an Algorithm
Perform a walkthrough to make sure your algorithm works
"Tracing" a program - pretend to be the computer and see what the program does
Desk checking - trace the program with paper and pencil before putting it into the computer
![Page 32: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/32.jpg)
32
Structures
A programmer has to choose them Data structures
variables, strings, vectors and matrices, trees allow the programmer to manipulate the data with actions like addition, comparison, display
Control structures dictate the order the statements are executed in
![Page 33: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/33.jpg)
33
![Page 34: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/34.jpg)
34
Control Structures
Sequence control structuresimplest structurestatements done in order from start to finishone entrance, one exitno unconditional transfers out of sequence
= "spaghetti code"
![Page 35: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/35.jpg)
35
Control Structures
Selection control structure
The computer executes a decisionindicated on the flowchart by the question in the diamond shape.
CLICK TO START
![Page 36: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/36.jpg)
36
Control Structures
Repetition control structure
To execute a loop, the computerrepeats one or more commands until some condition indicates that the looping should stop.
CLICK TO START
![Page 37: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/37.jpg)
37
Control Structures
Subroutines, procedures, and functions are sections of code that are part of the program, but not included in the main execution path
![Page 38: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/38.jpg)
38
Guarantees for Control Structures
One-entry-point, one-exit-point rule No infinite loops or logic errors No “Spaghetti Code” No dead code
![Page 39: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/39.jpg)
39
Programming Languages Selecting the right language:
Speed of execution, speed of development Organizational resources available
Space, programmers Type of target application Portability
Visual Basic
C / C++Java HTML
JavaScriptVBScript
ASP / JSP
Flash / XML
![Page 40: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/40.jpg)
40
FORTRAN - formula translator
The oldest high-level programming language; designed for scientific and mathematical applications.
John Backus
![Page 41: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/41.jpg)
41
COBOL - common business oriented language
designed for business transaction processing.
Grace
Hopper
![Page 42: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/42.jpg)
42
Pascal - named after Blaise Pascal, French scientist
designed to teach structured programming; useful for math and science applications.
Niklaus
Wirth
![Page 43: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/43.jpg)
43
Visual Basic Used to build Windows
applications Object-oriented
language Visual Basic 2005 is the
current version
Sample Visual Basic
![Page 44: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/44.jpg)
44
C and C++ C
Developed for system programmers
Combines high and low level programming features
Modern operating systems written in C
C++ Uses the same features
as C Includes object-oriented
design
Sample C
Sample C++
![Page 45: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/45.jpg)
45
Java Object-oriented features Large set of existing classes Architecture neutral Java applets: Small Java-based programs
![Page 46: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/46.jpg)
46
Web Applications
HTML/XHTML Hypertext Markup Language/Extensible Hypertext
Markup Language Not a true programming language Uses special symbols (tags) to control how Web
pages are viewed Extensible Markup Language (XML)
Enables computers to efficiently transfer information between Web sites
![Page 47: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/47.jpg)
47
Web Applications JavaScript
Used to make Web pages more visually appealing and interactive
VBScript A subset of Visual Basic Used to add interactivity to Web pages
PHP Another scripting language gaining popularity
Dynamic Decision Making Web page has the ability to display content based on user
choices
![Page 48: 1 Technology in Action Chapter 7 Behind the Scenes: Software Programming](https://reader033.vdocuments.net/reader033/viewer/2022052603/56649e025503460f94aec23c/html5/thumbnails/48.jpg)
48
Web Applications
Active Server Pages (ASP) and Java Server Pages (JSP) Adds interactivity capabilities to Web pages Translates user information into a request for
more information from a company’s computer Flash
Enables elaborate animations to be created for Web pages