Download presentation
Presentation is loading. Please wait.
Published byGyles Hampton Modified over 9 years ago
1
1 Technology in Action Chapter 7 Behind the Scenes: Software Programming
2
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
3
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
4
4
5
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
6
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
7
7 Program Development Life Cycle Step 5 Finishing the Project Step 4 Debugging Step 3 Coding Step 2 Making a Plan Step 1 Describing the Problem
8
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
9
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:INPUTOUTPUTNOTES 88*7.32Testing positive input 33*7.32Testing positive input 128*7.32 + 4*11.73Testing overtime input –6–6 Error message/ask user to reenter value Handling error Parking Garage Example
10
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 YesNo 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
11
11 Flowchart and Pseudocode Underlined words are information items that appear repeatedly in the algorithm. 1. Ask the user how many hours they worked today 2. If the number of hours worked < = 8, compute total pay without overtime otherwise, compute total pay with overtime pay 3. Print total pay Bold terms show actions that are common in programming, such as reading data, making decisions, printing, and so on. Flowchart Pseudocode
12
12 Top-Down Design Problem is divided into a series of high-level tasks Detailed subtasks are created from high-level tasks
13
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
14
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
15
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
16
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
17
17 Programming Languages Fifth-generation languages Hypothetical based on natural (human) languages
18
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
19
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
20
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?
21
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
22
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
23
23 Program Coding A program editor is a type of text editor specially designed for entering code for computer programs
24
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
25
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
26
26 Program Documentation Remarks or “comments” are a form of documentation that programmers insert into the program code
27
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
28
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 data calculate SquareInchPrices
29
29 Expressing an Algorithm Flowchart The pizza program flowchart illustrates how the computer should proceed through the instructions in the final program. CLICK TO START
30
30
31
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
32
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
33
33
34
34 Control Structures Sequence control structure simplest structure statements done in order from start to finish one entrance, one exit no unconditional transfers out of sequence = "spaghetti code"
35
35 Control Structures Selection control structure The computer executes a decision indicated on the flowchart by the question in the diamond shape. CLICK TO START
36
36 Control Structures Repetition control structure To execute a loop, the computer repeats one or more commands until some condition indicates that the looping should stop. CLICK TO START
37
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
38
38 Guarantees for Control Structures One-entry-point, one-exit-point rule No infinite loops or logic errors No “Spaghetti Code” No dead code
39
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 JavaScript VBScript ASP / JSP Flash / XML
40
40 FORTRAN - formula translator The oldest high- level programming language; designed for scientific and mathematical applications. John Backus
41
41 COBOL - common business oriented language designed for business transaction processing. Grace Hopper
42
42 Pascal - named after Blaise Pascal, French scientist designed to teach structured programming; useful for math and science applications. Niklaus Wirth
43
43 Visual Basic Used to build Windows applications Object-oriented language Visual Basic 2005 is the current version Sample Visual Basic
44
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++
45
45 Java Object-oriented features Large set of existing classes Architecture neutral Java applets: Small Java-based programs
46
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
47
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
48
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.