© Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12...

46
© Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages

Transcript of © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12...

Page 1: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-1

Chapter 12 Programming Concepts and Languages

Chapter 12Programming Concepts and Languages

Page 2: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-2

Presentation Overview

• Programming Concepts• Problem-Solving Techniques• The Evolution of Programming Approaches• Programming Development and Documenta

tion Tools• Programming Errors• The Software Development Life Cycle• Major Programming Languages

Page 3: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-3

Programming Concepts

• A program is a set of instructions telling a computer how to perform various tasks.

• A programming language is used by programmers to create a program.

• Programs are also referred to as source code.

• Coding is the act of writing source code.

Page 4: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-4

Programming Concepts

Language Characteristics and Classifications– Programming languages contain smaller

vocabularies than human languages.– Programming language syntax, or structure,

also tends to be less complex.– A program with a single syntax error (a

mistake in the way programming elements are strung together) will not work at all.

Page 5: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-5

Programming Concepts

High-Level vs. Low Level Languages– A low-level language is a binary language

consisting of 1s and 0s.• It is also known as machine code.• It runs faster and takes up less disk space.

– A high-level language is relatively similar to natural languages such as English.• It is easier to learn and use.

Page 6: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-6

Programming Concepts

• A computer programming language generation is a group of languages that were developed at the same time.

• Each generation builds on the contributions of the one before it.

Page 7: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-7

Programming Concepts

Classic Programming Elements– The four main programming elements are:

• variables – data values stored in computer memory• executable statements – perform actions and

proceed to the next statement in the sequence• looping – allows a program to return to a previously

executed instruction and repeat it• decision statements – points in a program where

different actions may be performed depending on specific conditions

Page 8: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-8

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.

Page 9: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-9

Programming Concepts

A Decision Statement’s Effect on Program Looping

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.

Page 10: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-10

Problem-Solving Techniques

In the divide-and-conquer approach, programmers tackle one small piece of the puzzle at a time.

The top-down design approach helps programmers break a large project into manageable parts.

Page 11: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-11

Problem-Solving Techniques

Problem-Solving Steps1. Identify the problem.

2. Analyze the problem

3. Brainstorm solutions and choose the best one.

4. Write the algorithm.

5. Prototype the solution.

6. Implement and test the solution.

Page 12: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-12

Problem-Solving Techniques

• An algorithm is a complete list of steps for solving a problem.

• Algorithms are written in pseudocode.

• The step-by-step pseudocode algorithm for changing a lightbulb appears at left.

Page 13: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-13

The Evolution of Programming Approaches

Structured Programming– This type of programming presents guidelines

for an organized, logical approach to programming.

– The programmer thinks in terms of structured groups of instructions built on routines, which are sections of programs that handle specific functions.

Routines are then broken down into steps.

Page 14: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-14

The Evolution of Programming Approaches

Modules– In modular code, programmers create code

modules that handle the separate components of a program.• Modules are reusable and help in tracking down the

source of errors.• Modularity describes how well source code is

divided into individual modules.

– A macro is a recording of steps to perform a repetitive activity.

Page 15: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-15

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.

Page 16: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-16

The Evolution of Programming Approaches

Rapid Application Development– Rapid application development (RAD)

reduces cost by decreasing time needed to develop a project.

– Visual Basic, Delphi, and other high-level languages with good interface capabilities are often used to aid in RAD.

Page 17: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-17

The Evolution of Programming Approaches

Rapid Application DevelopmentProgrammers using RAD follow these guidelines:

• Use visual development tools whenever possible.• Rapidly prototype new projects in order to reduce

redesign time.• Approach coding with these priorities:

– Use existing code first.– Buy someone else’s existing code second.– Write new code last.

Page 18: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-18

Programming Development and Documentation Tools

Compilers and Interpreters– A compiler is a program that translates

programming language source code into machine code.

– An interpreter translates instructions one-by-one as the source code is being executed, rather than all at once.

It identifies errors as they are encountered.

Page 19: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-19

Programming Development and Documentation Tools

Debuggers– A bug is a computer error.– A debugger is a software tool that helps

programmers find errors quickly.– Debuggers are an integral component of

compilers and interpreters.

Page 20: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-20

Programming Development and Documentation Tools

Documentation Tools– The written notes that explain how a program

works are called documentation.• A flowchart provides a visual diagram of an

algorithm.• CASE tools help a programming team schedule and

coordinate its operations.• A comment is an informational message inserted

into program source code to explain it to later readers.

Page 21: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-21

Programming Development and Documentation Tools

Flowchart SymbolsThese symbols are used in flowcharts to represent the logic of a program.

Page 22: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-22

Programming Development and Documentation Tools

Algorithm FlowchartFlowcharts help programmers visualize the steps in a software program.

Page 23: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-23

Programming Development and Documentation Tools

C++ Source Code Fragment Containing Comments– Comments help other programmers understand how the

program works. – A set of forward slashes (//) indicates the start of a

comment. – A hard return indicates the end of the comment.

Page 24: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-24

Programming Errors

What are the main types of program errors?– A syntax error is usually due to a typing

mistake or a misunderstanding of the rules of a language.

– A logic error occurs when a program’s syntax is correct, but the program instructs the computer to perform an action incorrectly.

Page 25: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-25

Programming Errors

What are the main types of program errors?– A run-time error refers to mistakes that occur

when the application is running.• A crash bug causes a program to stop running.• An infinite loop causes a program to perform the

same set of instructions over and over.

– A style error occurs as a result of poorly written programming code.

Dead code makes source code hard to read.

Page 26: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-26

The Software Development Life Cycle

What are the steps in the software development life cycle (SDLC)?

– The SDLC involves the planning, designing, implementing, testing, and release of application software.

Page 27: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-27

Major Programming Languages

Commonly Used Programming Languages

Page 28: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-28

Major Programming Languages

Machine Code– The computer programming language that

computers actually read and interpret.– The code is written using a series of binary

strings, which are sequences of binary symbols.

– Programming is rarely done using machine code because it is difficult to memorize.

Page 29: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-29

Major Programming Languages

Assembly Language– Symbols and words are used to represent the

elements of machine code, making it possible for programmers to memorize them.

– It runs the fastest and uses the least memory.– Assembly language programs are difficult to

write, which lengthens development times.

Page 30: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-30

Major Programming Languages

COBOL– An acronym for COmmon Business-Oriented

Language.– Used chiefly for business applications by large

companies.– A slow and cumbersome language. – It has large body of existing code. – Many programmers are familiar with it.

Page 31: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-31

Major Programming Languages

RPG– An acronym for Report Program Generator.– Commonly used in business environments.– It is often used on midrange and mainframe

computers.– It is slow and inefficient, but simplifies the

coding of database applications.– It is familiar to many programmers.

Page 32: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-32

Major Programming Languages

FORTRAN– An acronym for “FORmula TRANslator.” – Was for many years the language of choice for

math, science, and engineering projects.– It is still in use today in factories and

laboratories, but is not as common as COBOL.

Page 33: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-33

Major Programming Languages

BASIC– An acronym for “Beginner’s All-purpose

Symbolic Instruction Code.” – A high-level language. – It is more natural than COBOL and FORTRAN.– Today, BASIC is used professionally in an

updated form, often Visual Basic.– It runs slowly, but is faster to develop.

Page 34: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-34

Major Programming Languages

Example of BASIC Source CodeThis sequence of code will print the numbers 1 to 10.

Page 35: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-35

Major Programming Languages

Visual Basic– Developed by Microsoft in the early 1990s. – The professional’s language of choice for

developing software prototypes and custom interfaces.

– VB programs are quick and easy to develop, but run slowly and demand a lot of RAM and disk space.

– VB supports graphic interfaces.

Page 36: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-36

Major Programming Languages

C– Originally developed for the UNIX operating

system. – Named because it builds on an earlier language

called “B.”– C is a compromise between high- and low-level

languages, but is considered a high-level language.

– C programs aren’t as easy to read as BASIC, but they run faster and use less disk space.

Page 37: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-37

Major Programming Languages

C++– A superset of C, with added features such as

object-oriented programming.– Any C program should run without problems as

a C++ program.– Most professional software sold today is

written in the form of C or C++.

Page 38: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-38

Major Programming Languages

Example of C++ Source Code

This sequence of code will print the numbers 1 to 10.

Page 39: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-39

Major Programming Languages

C#– Pronounced “See-Sharp.” – An object-oriented language derived from C++

and Java.– It combines the productivity of Visual Basic

with the power of C++.– It allows use of features in the Microsoft.NET

framework, C, and Microsoft’s Component Object Model (COM).

Page 40: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-40

Major Programming Languages

Java– Widely used on the Internet as a script language

for Web page applications.– It is composed of applets that have cross-

platform compatibility, meaning they can run on all types of computer systems.

– The Java Virtual Machine (JVM) converts the Java instructions into commands that a computer can understand.

Page 41: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-41

Major Programming Languages

Scripting Languages– An interpreted language that is relatively easy

to learn and use.It is a nonprocedural language— it explains what the computer should do in English-like terms, but not precisely how to do it.

– Hypertext Markup Language (HTML), JavaScript, VBScript, and perl are scripting languages.

Page 42: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-42

Major Programming Languages

Example of JavaScriptThis sequence of code directs a browser to display buttons that users can click to change the background color within the Web browser window.

Page 43: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-43

Major Programming Languages

Dynamic HTML (DHTML)– Allows Web page designers to alter the content

of a Web page screen dynamically.– Displays faster than HTML.– DHTML pages are higher quality in appearance

and are more graphically responsive.– DHTML uses an object-oriented programming

model called document object model (DOM).

Page 44: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-44

Major Programming Languages

Extensible HTML– Lets Web designers use HTML and Extensible

Markup Language (XML) together.– XHTML allows screens with different sizes and

resolutions to display the same Web page content without the designer having to write specialized versions for each.

Page 45: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-45

Major Programming Languages

Wireless Markup Language (WML)– Created for small systems such as cell phones

and handheld computers.– Allows designers to build pages that work for

small screens.

Page 46: © Paradigm Publishing, Inc. 12-1 Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages.

© Paradigm Publishing, Inc. 12-46

On the Horizon

Based on the information presented in this chapter and your own experience, what do you think is on the horizon?