49
Computers Are Your Future Tenth Edition Chapter 11: Programming Languages & Program Development Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 1

Computers Are Your Future Tenth Edition Chapter 11: Programming Languages & Program Development Copyright © 2009 Pearson Education, Inc. Publishing as

Embed Size (px)

Citation preview

Computers Are Your FutureTenth Edition

Chapter 11: Programming Languages & Program

Development

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 1

2

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic,

mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. Printed in the United States of America.

Copyright © 2009 Pearson Education, Inc.  Publishing as Prentice Hall

What You Will Learn

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 3

Explain what a programming language is.

Contrast machine language and assembly language.

Discuss the benefits and drawbacks of high-level programming languages.

Explain how object-oriented languages attempt to remedy the shortcomings of earlier languages.

What You Will Learn

List several popular object-oriented languages and explain their advantage over older languages.

List the six phases of the program development life cycle (PDLC) and explain why the PDLC is needed.

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 4

What You Will Learn

Explain why top-down program design makes programs easier to debug and maintain.

List the three basic types of control structures and the advantages of each.

Differentiate between syntax errors and logic errors in programs.

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 5

Programming Language & Program Development

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 6

Development of Program Languages

Programming is the creation of software applications.

Programmers are the people who create the software applications.

A programming language is a language used by programmers to create programs or software that the computer understands.

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 7

Development of Program Languages

Syntax is the vocabulary and “grammar” of a programming language.

Code is the programming instructions created by the programmers.

Source code, the only form of code that humans can read, is program code in its original form.

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 8

Development of Program Languages

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 9

Development of Program Languages

There are five distinct programming language generations, or levels: Machine language Assembly language Procedural languages Nonprocedural languages Natural languages

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 10

Development of Program Languages

Machine language First-generation

language Based on binary

numbers The only

programming language a computer understands directly

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 11

Development of Program Languages

Assembly language A low-level, second-generation

language Requires programming individual

instructions for each task to be performed by the microprocessor

Mnemonics Uses brief abbreviations for program

instructions Makes language easier to use than machine

languageCopyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 12

Development of Program Languages

Procedural languages Third-generation languages Considered high-level languages Do not require programmers to know

details relating to the processing of data Easier to read, write, and maintain

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 13

Development of Program Languages

Two utility programs that translate code so that the computer can interpret and run programs are: Compilers

Translate source code into object code

Interpreters Translate source

code and execute instructions

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 14

Development of Program Languages

Categories of Procedural Language Structured programming

languages A solution to spaghetti code

Lots of GOTO statements Difficult to follow and prone to errors

A set of standards to make programs more readable, reliable, and maintainable

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 15

Development of Program Languages

Categories of Procedural Language (continued) Modular programming languages

Divide programs into self-contained modules

Use information hiding: keeping information about one module secret from authors of other modules

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 16

Development of Program Languages

Nonprocedural languages Fourth-generation languages

Report generators (database reports) Query languages

SQL (structured query language) Doesn’t require programmers to deal with

step-by-step procedures to achieve the appropriate programming outcome

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 17

Development of Program Languages

Natural language Fifth-generation languages Still being perfected Nonprocedural Use everyday language to program

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 18

Development of Program Languages

Object-oriented programming (OOP) Coding is attached to basic prebuilt

items called objects, which include: Data Procedures or operations called methods An interface to exchange messages with

other objects

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 19

Development of Program Languages

Object-oriented programming (OOP) (continued) Makes information hiding or

encapsulation a reality Examples of object-oriented

programming languages are C++, Java, and Visual Basic.NET

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 20

Development of Program Languages

Elements of object-oriented programming Objects: units of computer

information Classes: categories of objects Reusability of objects Inheritance: ability to pass on

characteristics to subclasses

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 21

Development of Program Languages

Rapid application development (RAD) Made possible by object-oriented

programming Relies on reusability of objects

Joint application development (JAD) Similar to RAD but involves end-user in

planningCopyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 22

Development of Program Languages

Advantages of OOP: Allows networked computers to query

objects through middleware Does not require code to be changed

when data is modified Promotes thinking in a real-world

environment, resulting in more effective programs

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 23

A Guide to Programming Languages: One Size Doesn’t Fit All

Programmers must select the programming language that can best meets the user’s needs.

Two programming languages that have been used since the 1950s are: COBOL (Common Business-

Oriented Language) for business applications

Fortran (formula translator) for scientific/math/engineering applicationsCopyright © 2009 Pearson Education, Inc. Publishing as Prentice

Hall 24

A Guide to Programming Languages: One Size Doesn’t Fit All

Structured and modular languages Required for large-scale program

development Examples

Ada BASIC Visual Basic Pascal C

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 25

A Guide to Programming Languages: One Size Doesn’t Fit All

Object-oriented languages Provide easier programming

techniques Examples

Smalltalk C++ Java Visual Basic.NET

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 26

A Guide to Programming Languages: One Size Doesn’t Fit All

Web-based languages Not considered programming

languages Enable the interpretation of both text

and objects by browsers Two types:

Markup languages Scripting languages

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 27

A Guide to Programming Languages: One Size Doesn’t Fit All

Markup languages Define text structure through a set of

instructions that are identified with tags.

Content lies between tags.

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 28

A Guide to Programming Languages: One Size Doesn’t Fit All

Types of markup languages include: HTML (Hypertext Markup Language) XML (Extensible Markup Language) XHTML (eXtensible Hypertext Markup

Language

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 29

A Guide to Programming Languages: One Size Doesn’t Fit All

Scripting languages Use basic programs called scripts to

control Web page actions or responses

Types of scripting languages include: VBScript JavaScript Visual Studio.NETCopyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 30

The Program Development Life Cycle

Program development life cycle (PDLC) Used to overcome debugging and

maintenance problems Made up of six phases, from problem

definition through program implementation and maintenance

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 31

The Program Development Life Cycle

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 32

The Program Development Life Cycle

Phase 1: Defining the problem Before a program can be developed,

the problem to be resolve must be defined.

This phase includes the definition of the program specifications, which include decisions regarding data input, required processing, output, and the user interface.

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 33

The Program Development Life Cycle

Phase 2: Designing the program This phase develops a plan of

program specifications. Top-down program design

Breaks program into small, manageable, highly focused subroutines

Results in better control programming, easier debugging, and efficient maintenance

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 34

The Program Development Life Cycle

Phase 2: Designing the program (continued) Control structures

Logically assembled blocks of code Used to determine how subroutines will be

programmed

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 35

The Program Development Life Cycle

Phase 2: Designing the program (continued) The basic control structures categories

are: Sequence: Code performed in line-by-line

order Selection (also conditional or branch):

Portion of code that leads to a block of code based on conditions being met

Case: A portion of code that branches to extensive coding

Repetition (also looping or iteration): A portion of code that repeats

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 36

The Program Development Life Cycle

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 37

The Program Development Life Cycle

Phase 2: Designing the program (continued) Algorithm

A combination of control structures A step-by-step accounting of how to

arrive at a solution

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 38

The Program Development Life Cycle

Phase 2: Designing the program (continued) Program design tools used during this

phase: Structured charts: show top-down design

of programs Flowcharts: show logic of program Pseudocode: stylized form of writing to

describe logic

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 39

The Program Development Life Cycle

Phase 3: Coding the program Programmers take the algorithms and

convert them into programming code. Syntax errors

Mistakes in the construction of the programming commands

Must be corrected for the program to run appropriately

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 40

The Program Development Life Cycle

Phase 4: Testing and debugging the program All errors, not just syntax errors, must

be removed. Logic errors

Relate to problems in the solution’s design Cause incorrect output Program still runs even though logic errors

existCopyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 41

The Program Development Life Cycle

Phase 5: Documenting the program The creation of written

documentation is of paramount importance.

Documentation includes: Overview of the functionality of the

program Tutorials Thorough reviews of the main features Reviews of error messages Record of program design work

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 42

The Program Development Life Cycle

Phase 6: Implementing and maintaining the program Testing of the program takes place.

Users work with the software. Problems or errors to be corrected are

determined. Once the program is finalized,

continual maintenance and evaluation must be performed.

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 43

What You’ve Learned

A programming language, which is made up of its own vocabulary and syntax, creates instructions that a computer understands.

Machine language is based on binary code. Assembly language is similar but a little easier to understand than machine language. Both are difficult and demanding compared to later languages.Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 44

What You’ve Learned

Unlike machine and assembly languages, third-generation (high-level) programming languages do not require programmers to have a thorough understanding of processor details.

Fourth-generation languages, although even easier for programmers to use, are mostly restricted to accessing databases.

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 45

What You’ve Learned

Object-oriented programming languages work with prebuilt objects for fast, even simpler programming when compared to earlier-generation languages.

The program development life cycle (PDLC) minimizes errors and maintenance problems.

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 46

What You’ve Learned

The six phases of the program development life cycle (PDLC) are (1) defining the problem, (2) designing the program, (3) coding the program, (4) testing and debugging the program, (5) documenting the program, and (6) implementing and maintaining the program.

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 47

What You’ve Learned

Debugging and maintaining programs using top-down program design are simpler because program functions are divided into separate modules.

Algorithms to perform any processing task can be created by programmers using sequence, selection, and repetition control structures.

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 48

What You’ve Learned

There are two types of bugs: syntax errors, which are errors caused by faulty command structure, and logic errors, which are errors caused by faulty programming design.

Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall 49