Top Banner
Programming Languages: Telling the Computers What to Do Chapter 16
38

Programming Languages: Telling the Computers What to Do Chapter 16.

Dec 25, 2015

Download

Documents

Kelley Webb
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Programming Languages: Telling the Computers What to Do Chapter 16.

Programming Languages: Telling the Computers

What to Do

Chapter 16

Page 2: Programming Languages: Telling the Computers What to Do Chapter 16.

Objectives

• Describe what programmers do and do not do

• Explain how programmers define a problem, plan the solution and then code, test, and document the program

• List and describe the levels of programming languages – machine, assembly, high level, very high level, and natural

• Describe the major programming languages in use today

• Explain the concepts of object-oriented programming

Page 3: Programming Languages: Telling the Computers What to Do Chapter 16.

Contents

• Program

• Programmers

• The Programming Process

• Choosing a Language

• Traditional Programming

• Object-Oriented Programming

• Learning to Program

Page 4: Programming Languages: Telling the Computers What to Do Chapter 16.

Program

Set of instructions written in a programming language that tells the

computer what to do

Page 5: Programming Languages: Telling the Computers What to Do Chapter 16.

Programmers• Prepare instructions that make up the program

• Run the instructions to see if they produce the correct results

• Make corrections

• Document the program

• Interact with– Users– Managers– Systems analysts

• Coordinate with other programmers to build a complete system

Page 6: Programming Languages: Telling the Computers What to Do Chapter 16.

The Programming Process

• Defining the problem

• Planning the solution

• Coding the program

• Testing the program

• Documenting the program

Page 7: Programming Languages: Telling the Computers What to Do Chapter 16.

The Programming ProcessDefining the Problem

• What is the input

• What output do you expect

• How do you get from the input to the output

Page 8: Programming Languages: Telling the Computers What to Do Chapter 16.

The Programming ProcessPlanning the Solution

• Algorithm – detailed solution to a problem

• Design tools– Flowchart– Pseudocode

• Desk-checking

• Structured walkthrough

Page 9: Programming Languages: Telling the Computers What to Do Chapter 16.

The Programming ProcessPlanning the Solution

Accept series of numbersand display the average

Page 10: Programming Languages: Telling the Computers What to Do Chapter 16.

The Programming ProcessPlanning the Solution

Accept series of numbers and display the average

Page 11: Programming Languages: Telling the Computers What to Do Chapter 16.

The Programming ProcessCoding the Program

• Translate algorithm into a formal programming language

• Syntax

• How to key in the statements?– Text editor– Programming environment – Interactive

Development Environment (IDE)

Page 12: Programming Languages: Telling the Computers What to Do Chapter 16.

The Programming ProcessTesting the Program

• Translation – compiler– Translates from source module into object module– Detects syntax errors

• Link – linkage editor (linker)– Combines object module with libraries to create

load module– Finds undefined external references

• Debugging– Run using data that tests all statements– Logic errors

Page 13: Programming Languages: Telling the Computers What to Do Chapter 16.

The Programming ProcessTesting the Program

Page 14: Programming Languages: Telling the Computers What to Do Chapter 16.

The Programming ProcessDocumenting the Program

• Performed throughout the development

• Material generated during each step– Problem definitions– Program plan– Comments within source code– Testing procedures– Narrative– Layouts of input and output– Program listing

Page 15: Programming Languages: Telling the Computers What to Do Chapter 16.

Choosing a Language

• Choice made for you– What is available?– Required interface

• What do you know best?

• Which language lends itself to the problem to be solved?

Page 16: Programming Languages: Telling the Computers What to Do Chapter 16.

Language Generations

• Low levels closer to binary

• High levels closer to human code

• Five Generations:– Procedural Languages

• Machine language• Assembly language• High-level language – 3GL

– Nonprocedural Languages• Very high-level language – 4GL• Natural language – 5GL

Page 17: Programming Languages: Telling the Computers What to Do Chapter 16.

Machine Language

• Written in strings of 0 and 1

• Only language the computer understands

• All other programming languages are translated to machine language

• Computer dependent

Page 18: Programming Languages: Telling the Computers What to Do Chapter 16.

Assembly Language

• Mnemonic codes

• Names for memory locations

• Computer dependent

• Assembler translates from Assembly to machine language

Page 19: Programming Languages: Telling the Computers What to Do Chapter 16.

3GLHigh-Level Languages

• 1960s

• Languages designed for specific types of problems and used syntax familiar to the people in that field– FORTRAN: math– COBOL: business

• Compile translates from high-level language to machine language

Page 20: Programming Languages: Telling the Computers What to Do Chapter 16.

4GLVery High-Level Languages

• Programmer specifies the desired results; the language develops the solution

• Ten times more productive with a 4GL than a procedural language

• Query Languages– Retrieve information from databases– Easy to learn and use

Page 21: Programming Languages: Telling the Computers What to Do Chapter 16.

5GLNatural Languages

• Resemble natural or spoken English

• Translates human instructions into code the computer can execute

• Commonly used by non-programmers to access databases

Page 22: Programming Languages: Telling the Computers What to Do Chapter 16.

Third Generation LanguagesTraditional Programming

• Describe data

• Describe procedures or operations on that data

• Data and procedures are separate

Page 23: Programming Languages: Telling the Computers What to Do Chapter 16.

Third Generation Languages

• FORTRAN– 1954– Represent complex mathematical formulas– C/C++ has replaced FORTRAN

• COBOL– 1959– Business– Large complex data files– Formatted business reports

Page 24: Programming Languages: Telling the Computers What to Do Chapter 16.

Third Generation Languages

FORTRAN

Page 25: Programming Languages: Telling the Computers What to Do Chapter 16.

Third Generation Languages

COBOL

Page 26: Programming Languages: Telling the Computers What to Do Chapter 16.

Third Generation Languages

• BASIC– 1965– Popularity grew with PC popularity (1970s)– Easy to learn– Used little memory

• RPG– 1965– Report generation – quickly creates complex

reports

Page 27: Programming Languages: Telling the Computers What to Do Chapter 16.

Third Generation Languages

BASIC

Page 28: Programming Languages: Telling the Computers What to Do Chapter 16.

Third Generation Languages• Visual Basic

– 1987– Create complex user interfaces– Uses standard Windows features– Event-driven – user controls the program

• C– 1972– Efficient code– Portability

• C++– Enhancement of C

Page 29: Programming Languages: Telling the Computers What to Do Chapter 16.

Third Generation Languages

C++

Page 30: Programming Languages: Telling the Computers What to Do Chapter 16.

OOPObject-Oriented Programming• Object

– Self-contained unit of data and instructions– Includes

• Related facts (data)• Related functions (instructions to act on that data)

• Example– Object: cat– Data: feet, nose, fur, tail– Functions: eat, purr, scratch, walk– Cat: Kitty, Susan

Page 31: Programming Languages: Telling the Computers What to Do Chapter 16.

OOPObject-Oriented Programming• Encapsulation – describes the objects self-

containment

• Attributes – the facts that describe the object

• Methods / operations – the instructions that tell the object what to do

• Instance – one occurrence of an object

• Messages – activate methodsExample: A walk message causes Kitty to move

Page 32: Programming Languages: Telling the Computers What to Do Chapter 16.

OOPObject-Oriented Programming• Class – defines characteristics unique to all

objects of that class

• Inheritance – Objects of a class automatically posses all of the characteristics of the class from which it was derived

• Subclass – inherits characteristics from class and defines additional characteristics that are unique

Page 33: Programming Languages: Telling the Computers What to Do Chapter 16.

OOPObject-Oriented Programming

ExampleClass: AnimalSubclass: CatSubclass: Persian catInstance: Kitty

Objects can be reused

Page 34: Programming Languages: Telling the Computers What to Do Chapter 16.

OOPObject-Oriented Programming

Languages

• C++Can write both structured and object-oriented code

• Visual BasicRudimentary features of object-oriented language

Page 35: Programming Languages: Telling the Computers What to Do Chapter 16.

Third Generation Languages

Java

• Cross-platform

• Java Virtual Machine (JVM)– Sits on top of computer’s regular platform– Translates compiled Java code into

instructions for the specific platform

• Applets

Page 36: Programming Languages: Telling the Computers What to Do Chapter 16.

OOPObject-Oriented Programming

Using Objects in BusinessClass: CustomerSubclass: Retail or WholesaleInstance: John Smith

Retail and Wholesale customers automatically inherit customer address since it is part of the Customer class

Page 37: Programming Languages: Telling the Computers What to Do Chapter 16.

Learning to Program

• Enroll in courses

• Read

• Use tutorials

• View Sample code

• Write code (start small)

• Use Help

Page 38: Programming Languages: Telling the Computers What to Do Chapter 16.