Computers Are Your Future Twelfth Edition Chapter 11: Programming Languages and Program Development...

Post on 18-Jan-2018

218 views 0 download

description

Objectives Explain what a programming language is and how it works. Explain the development of programming languages over the years and the benefits and drawbacks of high-level programming languages. Explain how object-oriented languages attempt to remedy the shortcomings of earlier languages. Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 3

transcript

Computers Are Your FutureComputers Are Your FutureTwelfth EditionTwelfth Edition

Chapter 11: Programming Languages and Program Development

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

Programming Languages Programming Languages

and Program and Program DevelopmentDevelopment

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 2

ObjectivesObjectives• Explain what a programming

language is and how it works.• Explain the development of

programming languages over the years and the benefits and drawbacks of high-level programming languages.

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

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

ObjectivesObjectives• 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 © 2012 Pearson Education, Inc. Publishing as Prentice Hall 4

ObjectivesObjectives• Explain why defining the problem in

a top-down design manner leads to programs that are easier to debug and maintain.

• Differentiate between problems that can arise in the testing and debugging phase as syntax and logic errors.

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

Programming Languages Programming Languages

and How They Workand How They Work• Programming

o Process used to create software programs• Programmers

o People who use programming languages to create software applications

• Programming languageso Consist of a vocabulary and a set of rules

called syntax

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

Programming Languages Programming Languages

and How They Workand How They Work• Interface

o Point of interaction between components, such as the interaction between a user’s screen and the computer code, which results when running a program

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

Development of Development of Programming LanguagesProgramming Languages

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

Development of Development of Programming LanguagesProgramming Languages

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

• Compilers and interpreterso Source code—programming instructions in the

original form needed to translate a form that the computer can understand

o Code—programming instructions created by the programmers

o High-level language—language that mimics English; does not require a programmer to understand the intimate details of how hardware, especially the processor, handles data

Development of Development of Programming LanguagesProgramming Languages

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

Development of Development of Programming LanguagesProgramming Languages

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

• Compilers and interpreterso Compiler—utility program translates source

code into object codeo Executable program—code transformed

from object code ready to run programs that do not need to be altered

o Interpreter—translation program that does not produce object code—translates one line of source code at a time; executes the translated instruction

Development of Development of Programming LanguagesProgramming Languages

• Five generations of programming languageso Machineo Assemblyo Proceduralo Nonproceduralo Natural

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 12

Development of Development of Programming LanguagesProgramming Languages

• First-generation languageso Machine language

• Based on binary numbers• Only programming language that a

computer understands directly• Machine dependent

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

Development of Development of Programming LanguagesProgramming Languages

• Second-generation languageo Assembly language

• Low-level language• Programs use:

o Mnemonics—brief abbreviations for program instructions make assembly language easier to use

o Base-10 (decimal) numbers• Must be translated into machine language by an

assembler• Occasionally used to create device drivers

o Programs to control devices attached to a computer and game console programs

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

Development of Development of Programming LanguagesProgramming Languages

• Third-generation languageso High-level languages—do not require

programmers to know details relating to the processing of data

o Easier to read, write, and maintain than assembly and machine languages

o Source code must be translated by a language translator

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

Development of Development of Programming LanguagesProgramming Languages

• Third-generation languages (con’t.)o Spaghetti code—difficult to follow, messy in design,

prone to errors due to numerous GOTO statementso Structured programming—set of quality standards;

programs more verbose but more readable, reliable, and maintainableo GOTO statements forbiddeno Examples:

• Ada• Algol• Pascal

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

Development of Development of Programming LanguagesProgramming Languages

• Third-generation languages (con’t.)o Modular programming—dividing larger programs

into separate modules, each takes care of a specific function

o Information hiding—also known as encapsulation, modular programming makes it possible to hide details in sensitive applications

o Programming languages include:• Fortran• C

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

Development of Development of Programming LanguagesProgramming Languages• Procedural

languageso Provide detailed

instructions that are designed to carry out a specific action such as printing a formatted report

• Nonprocedural languageso Do not require

programmers to use step-by-step instructions

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

Development of Development of Programming LanguagesProgramming Languages

• Fourth-generation languageso Nonprocedural languageso Do not require step-by-step procedureso Examples

• Report generators (database reports)• Query languages

oSQL (Structured query language)—enables users to phrase simple or complex requests for data

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

Development of Development of Programming LanguagesProgramming Languages

• Fifth-generation languages o Natural languageo Still being perfectedo Nonproceduralo Use everyday language to program

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

Development of Development of Programming LanguagesProgramming Languages

• Object-oriented programming (OOP) o Programming technique based on data being

conceptualized as objects• Object—unit of computer information that

defines a data element that is used to model real-world objects

• Attributes define the data• Procedures or operations are called methods

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

Development of Development of Programming LanguagesProgramming Languages

• Object-oriented programming (OOP) (con’t.)o Class—blueprint or prototype from which objects

are madeo Inheritance—ability to pass on characteristics

from a class to subclasses

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 22

Development of Development of Programming LanguagesProgramming Languages

• Program development methodso Rapid application development (RAD)

• Reuses prebuilt objects• Possible because of OOP

o Joint application development (JAD)• Uses a team approach• Involves end users throughout development

o Agile software development techniques—use collaboration between teams to develop solutions to meet customer needs and company goals

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

Development of Development of Programming LanguagesProgramming Languages

• Middlewareo Makes connections between applications on

multiple networkso Integral to modern information technology

based on XML, Web services, and service-oriented architecture

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 24

A Guide to Programming A Guide to Programming Languages: Languages:

One Size Doesn’t Fit AllOne Size Doesn’t Fit All• Early high-level languages

o COBOL (Common Business-Oriented Language) • Used for business applications• Current focus is on editing aged code on mainframe

computerso Fortran (formula translator)

• Used for scientific/math/engineering applications• Being replaced by object-oriented and formula-solving

programs o Mathematica

• Used to handle all aspects of technical computing in a coherent and unified way

• Can manipulate a wide range of objects, using only a small number of basic elements

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

A Guide to Programming A Guide to Programming Languages: Languages:

One Size Doesn’t Fit AllOne Size Doesn’t Fit All• Structured and modular

languageso Required for large-scale program developmento Languages in widespread use:

• Ada• BASIC• Visual Basic

o Event-driven programming language that executes only in response to user actions

• C

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

A Guide to Programming A Guide to Programming Languages: Languages:

One Size Doesn’t Fit AllOne Size Doesn’t Fit All• Object-oriented languages

o Visual Studio.NET—Microsoft’s answer to Java and JavaScript

• Visual Basic.Net• Visual C++• Visual C#• F#—language that combines object-oriented

features with the assets of a functional languageo Functional language reflects the way people think

mathematically—useful in programs that express findings in mathematical form

• Integrated development environment (IDE)

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

A Guide to Programming A Guide to Programming Languages:Languages:

One Size Doesn’t Fit AllOne Size Doesn’t Fit All

• Web-based languageso Not considered programming languageso Tell the browser how to display text and

objectso Language types

• Markup• Scripting

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

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

AllAll

• Markup languages o Composed of a set of codes, or elements,

that uses tags to define how text and objects display

• Tags—markers that usually come in pairso Content—text that displays, lies between

the opening and closing tags

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

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

AllAll• Markup languages

o HTML (Hypertext Markup Language)• Used by Web programmers • Supports links to other documents, graphics, and audio and

video files.o XML (Extensible Markup Language)

• Enables programmers to capture specific types of data by creating their own elements

• Not a replacement for HTMLo XHTML (Extensible Hypertext Markup Language

• Newer version of HTML that uses XML to produce Web pages that are easily accessible by newer portable devices.

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 30

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

AllAll• Markup languages (con’t.)

o WML (Wireless Markup Language)enables developers to create pages for wireless devices

o CSS (Cascading Style Sheets)defines the look and formatting of a Web page

• World Wide Web Consortium (W3C)o International group—develops Web standardso Develops protocols and guidelines that ensure

long-term growth for the Web

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

A Guide to Programming A Guide to Programming Languages:Languages:

One Size Doesn’t Fit AllOne Size Doesn’t Fit All• Scripting languages

o Create scripts—programs that control Web page actions or responses

• VBScript• ActiveX controls• JavaScript• ECMAScript• AJAX• JSON

o Used for serialization and transmitting structured data over a network

• PHP

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

The Program The Program Development Life CycleDevelopment Life Cycle

• Program development life cycle (PDLC)o Organized plan for managing the

development of softwareo Consists of six phases, from problem

definition through program implementation and maintenance

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

The Program The Program Development Life CycleDevelopment Life Cycle

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

The Program The Program Development Life CycleDevelopment Life Cycle

• Phase 1: Defining the problemo Define the problem the program will solveo Define the program specifications, including

decisions regarding data input, required processing, output, and the user interface

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

The Program The Program Development Life CycleDevelopment Life Cycle

• Phase 2: Designing the programo Program design—identifies components of the

program• Top-down program design—breaks program

into small, manageable, highly focused routineso Procedures, functions, or subroutines

• Structured design uses control structures—logical elements assembled in blocks of code that determine how subroutines will be programmed

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

The Program The Program Development Life CycleDevelopment Life Cycle• Phase 2: Designing the program

(con’t.)o Basic control structures categories

• Sequence control structure—code performed in line-by-line order

• Selection control structure—also called a conditional or branch structure, this is a portion of code that leads to a block of code based on conditions being met

• Case control structure—portion of code that branches to extensive conditional coding

• Repetition control structure—also known as looping or iteration, this is a portion of code that repeats

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

The Program The Program Development Life CycleDevelopment Life Cycle• Phase 2: Designing the

program (con’t.)o Algorithm

• Combination of control structures • Step-by-step description of how to arrive at a

solutiono Nesting

• Process of embedding control structures within one another

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

The Program The Program Development Life CycleDevelopment Life Cycle

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

The Program The Program Development Life CycleDevelopment Life Cycle

• Phase 2: Designing the program (con’t.)o Program design tools

• Structured charts—also called hierarchy charts, show top-down design of programs

• Flowcharts—use diagrams to show the logic of a program

• Unified Modeling Language (UML)—variation of flowcharting used to illustrate and document object-oriented systems during development

• Pseudocode—uses a stylized form of writing to describe logic

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

The Program The Program Development Life CycleDevelopment Life Cycle

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 41

The Program The Program Development Life CycleDevelopment Life Cycle

• Phase 3: Coding the programo Programmers convert algorithms into

programming codeo Syntax errors

• Mistakes in the construction of the programming commands

• Must be corrected for the program to run appropriately

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

The Program The Program Development Life CycleDevelopment Life Cycle• Phase 4: Testing and

debugging the programo All errors, not just syntax errors, must be removedo Logic errors

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

o Syntax errors and logic errors—bugso Debugging—process of eliminating errors

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

The Program The Program Development Life CycleDevelopment Life Cycle• Phase 5: Documenting the program

o Documentation includes:• Overview of program functionality• Tutorials• Thorough explanation of main features • Reference documentation of program commands• Description of error messages• Program design work, including structure charts,

pseudocode, and flowcharts

Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 44

The Program The Program Development Life CycleDevelopment Life Cycle• Phase 6: Implementing and maintaining the programo Test the program

• Have users work with the software• Correct errors

o Program maintenance• Fix program errors discovered by users• Conduct periodic evaluations on a regular basis• Make modifications as needed to update the

program or add featuresCopyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 45

SummarySummary• Explain what a programming language

is and how it works.• Explain the development of

programming languages over the years and the benefits and drawbacks of high-level programming languages.

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

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

SummarySummary• 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 © 2012 Pearson Education, Inc. Publishing as Prentice Hall 47

SummarySummary• Explain why defining the problem in

a top-down design manner leads to programs that are easier to debug and maintain.

• Differentiate between problems that can arise in the testing and debugging phase as syntax and logic errors.

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

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 © 2012 Pearson Education, Inc.  Copyright © 2012 Pearson Education, Inc.  Publishing as Prentice HallPublishing as Prentice Hall

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