信息处理技术.

Slides:



Advertisements
Similar presentations
Agenda Definitions Evolution of Programming Languages and Personal Computers The C Language.
Advertisements

Chapter 12 Computer Programming
Chapter 12 Computer Programming.
Computers Are Your Future
Programming Creating programs that run on your PC
Introduction To System Analysis and Design
Overview of Programming Paradigms
Computers: Tools for an Information Age
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Chapter 1 Program Design
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Computer Programming.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
11 Computer Programming Section A Programming Basics CHAPTER
Your Interactive Guide to the Digital World Discovering Computers 2012.
Computer Programming and Database Handout
Introduction to High-Level Language Programming
Chapter 13 Programming Languages and Program Development 1.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
Computers Are Your Future Tenth Edition Chapter 11: Programming Languages & Program Development Copyright © 2009 Pearson Education, Inc. Publishing as.
Programming Languages – Coding schemes used to write both systems and application software A programming language is an abstraction mechanism. It enables.
Programming Languages: Telling the Computers What to Do Chapter 16.
Object Oriented Software Development
A First Program Using C#
Structured COBOL Programming, Stern & Stern, 9th edition
COMPUTER SOFTWARE Section 2 “System Software: Computer System Management ” CHAPTER 4 Lecture-6/ T. Nouf Almujally 1.
Microsoft Visual Basic 2005: Reloaded Second Edition
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
Welcome to OBJECT ORIENTED PROGRAMMIN Date: 10/09/2014 Prepared By Prepared By : VINAY ALEXANDER PGT(CS) KV jhagrakhand.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
UNIVERSITI TENAGA NASIONAL “Generates Professionals” CHAPTER 4 : Part 2 INTRODUCTION TO SOFTWARE DEVELOPMENT: PROGRAMMING & LANGUAGES.
COMPUTER PROGRAMMING Source: Computing Concepts (the I-series) by Haag, Cummings, and Rhea, McGraw-Hill/Irwin, 2002.
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
Introduction To System Analysis and Design
CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do.
Computer Concepts 2014 Chapter 12 Computer Programming.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Discovering Computers 2009 Chapter 13 Programming Languages and Program Development.
Computer Programs and Programming Languages What are low-level languages and high-level languages? High-level language Low-level language Machine-dependent.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
INTRODUCTION TO COMPUTING CHAPTER NO. 04. Programming Languages Program Algorithms and Pseudo Code Properties and Advantages of Algorithms Flowchart (Symbols.
Chapter 12 Computer Programming. Chapter Contents Chapter 12: Computer Programming 2  Section A: Programming Basics  Section B: Procedural Programming.
Copyright © Prentice Hall Programming and Languages Chapter 14 Telling the Computer What to Do.
Chapter 12 Computer Programming. 12 Chapter 12: Computer Programming 2 Chapter Contents  Section A: Programming Basics  Section B: Procedural Programming.
Computer Concepts 2013 Chapter 12 Computer Programming.
Module 4 Part 2 Introduction To Software Development : Programming & Languages Introduction To Software Development : Programming & Languages.
Computer Concepts 2014 Chapter 12 Computer Programming.
Unit 11 Programming.
Principles of Information Systems, Sixth Edition Software: Systems and Application Software Chapter 4.
Computer Concepts 2013 Chapter 12 Computer Programming.
Chapter 12: Computer Programming 1 Computer Programming Chapter 12.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
Software Design and Development Languages and Environments Computing Science.
Welcome to OBJECT ORIENTED PROGRAMMING Prepared By Prepared By : VINAY ALEXANDER PGT(CS) KV jhagrakhand.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Software Engineering Algorithms, Compilers, & Lifecycle.
PROGRAMMING (1) LECTURE # 1 Programming and Languages: Telling the Computer What to Do.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
OCR A Level F453: High level languages Programming techniques a. identify a variety of programming paradigms (low-level, object- oriented,
Your Interactive Guide to the Digital World Discovering Computers 2012 Chapter 13 Computer Programs and Programming Languages.
Computer Language
Unit 11 Programming.
Chapter 12 Computer Programming.
CSCI-235 Micro-Computer Applications
Computer Programming.
Chapter 12: Computer Programming
Chapter 1 Introduction(1.1)
Presentation transcript:

信息处理技术

Chapter 11: Computer Programming Chapter 1: Computer, Internet, Web, and E-Mail Basics Chapter 4: File Management, Virus Protection, and Backup 1 1 1 1

Chapter 11 Preview After this chapter, you should be able to: Describe the role of computer programmers and software engineers Categorize today’s popular computer programming languages by generation and paradigm Explain the process of planning, coding, and testing a computer program Describe the advantages and disadvantages of generic text editors, program editors, and VDEs for coding computer programs Define the term algorithm and describe how it relates to procedural programming Chapter 11: Computer Programming

Chapter 11 Preview Identify various tools that programmers use to plan programs, such as flowcharts, structured English, pseudocode, UML diagrams, and decision tables Follow the control structures for a procedural program Describe the major concepts of object-oriented programming, such as objects, classes, inheritance, messages, methods, polymorphism, and encapsulation Create some basic facts and rules using Prolog syntax Describe how a declarative language, such as Prolog, satisfies goals by instantiation Chapter 11: Computer Programming

Chapter 11 Outline Section A Section B Section C Section D Programming Basics Section B Procedural Programming Section C Object-Oriented Programming Section D Declarative Programming Chapter 11: Computer Programming

Chapter 11 Computer Programming 计算机程序 Section A: Programming Basics 程序基础 Computer Concepts 8th Edition

What is program code? A computer program is a set of detailed, step-by-step instructions that tell a computer how to solve a problem or carry out a task The instructions that make up a computer program are sometimes referred to as code Today, program code contains familiar English-like words Programs can exist as a single module or multiple modules Chapter 11: Computer Programming Page 570

What is program code? Chapter 11: Computer Programming Page 570

How big is a typical computer program? By the Department of Defense standards, anything you will work on in this chapter is “small”. “small”- a program with fewer than 100,000 lines of code “medium-sized”- a program with 100,000 to 1 million lines “large”- a program with more than 1 million lines Chapter 11: Computer Programming Page 571

Who creates computer programs? A computer programmer typically focuses on creating computer programs Coding refers to entering the list of commands that become a computer program The term computer programming encompasses a broad set of activities that include planning, coding, testing, and documenting Chapter 11: Computer Programming Page 571

A software engineer focuses on designing and testing activities What’s the difference between computer programming and software engineering? Software engineering refers to a program development process in which you reduce the cost and complexity of a computer program while increasing its reliability and modifiability A software engineer focuses on designing and testing activities Chapter 11: Computer Programming Page 571

What is a programming language? A set of keywords and grammar rules designed for creating instructions that can ultimately be processed, or executed, by the computer Keywords Parameters Syntax Chapter 11: Computer Programming Page 572

How are programming languages categorized? Low-level languages vs. high-level languages Generation Paradigm Chapter 11: Computer Programming Page 572

What is a low-level language? Typically includes commands that are specific to a particular CPU or microprocessor family Includes machine languages and assembly languages Chapter 11: Computer Programming Page 572

What is a high-level language? Hides the underlying low-level assembly or machine language, and provides command words and grammar that are more like human languages COBOL BASIC Java C Chapter 11: Computer Programming Page 572

What was the first generation of programming languages? Machine languages were the first languages available for programming computers First-generation languages A machine language provides a set of commands, represented as a series of 1s and 0s Chapter 11: Computer Programming Page 573

What is a second-generation language? An assembly language allows programmers to use abbreviated command words, called op codes, rather than 1s and 0s Classified as a low-level language Most often used to write system software Chapter 11: Computer Programming Page 573

What is a third-generation language? Third-generation languages use easy-to-remember command words to take the place of several lines of assembly language or endless strings of machine language COBOL FORTRAN Pascal C BASIC Chapter 11: Computer Programming Page 573

What is a fourth-generation language? Fourth-generation languages more closely resemble human languages Eliminate many of the strict punctuation and grammar rules complicating third-generation languages Typically used for database applications SQL RPG-I Chapter 11: Computer Programming Page 574

What about fifth-generation languages? Some believe a fifth-generation language is a computer programming language based on a declarative programming paradigm Other experts feel fifth-generation languages are those that allow programmers to use graphical or visual tools to construct programs Chapter 11: Computer Programming Page 574

Program Planning: How does a programmer plan a computer program? The programming process begins with a problem statement that helps you clearly define the purpose of a computer program Chapter 11: Computer Programming Page 576

What is a problem statement? Defines certain elements that must be manipulated to achieve a result or goal Specifies any assumptions that define the scope of the problem Clearly specifies the known information Specifies when the problem has been solved Chapter 11: Computer Programming Page 576

What is an assumption? Something that you accept as true in order to proceed with program planning Chapter 11: Computer Programming Page 576

How does “known information” apply to a problem statement? The known information in a problem statement is the information that you supply to the computer to help it solve a problem Chapter 11: Computer Programming Page 577

Program Coding: How do I code a computer program? It depends on: The programming language you use The programming tools that you selected The programming paradigm that best fits the problem you’re trying to solve Chapter 11: Computer Programming Page 577

What is a generic text editor? Chapter 11: Computer Programming Page 578

What is a program editor? A type of text editor specially designed for entering code for computer programs Chapter 11: Computer Programming Page 578

What is a VDE? Chapter 11: Computer Programming Page 579

How does a programmer know if a program works? A computer program must be tested to ensure that it works correctly Testing consists of running the program and entering test data to see whether the program produces the correct results Chapter 11: Computer Programming Page 581

What can cause program errors? A syntax error occurs when an instruction does not follow the syntax rules, or grammar, of the programming language A runtime error occurs when the computer can’t execute an instruction A logic error is an error in the logic or design of a program Chapter 11: Computer Programming Page 581

How do programmers find errors? Proofreading lines of code Programmers can also use a debugger, which allows programmers to step through a program and monitor the status of variables, input, and output Chapter 11: Computer Programming Page 581

Do computer programs contain any special documentation? Chapter 11: Computer Programming Page 582

Chapter 11 Computer Programming Section B: Procedural Programming 程序设计 Computer Concepts 8th Edition

What is procedural programming? The traditional approach to programming uses a procedural paradigm The procedural paradigm is used to conceptualize the solution as a sequence of steps Chapter 11: Computer Programming Page 584

Algorithms: What is an algorithm? A set of steps for carrying out a task Carefully following the steps of a correctly formulated algorithm guarantees that you can accomplish the task for which the algorithm was designed Chapter 11: Computer Programming Page 584

How do I write an algorithm? Written in a format that is not specific to a particular programming language This approach allows the programmer to focus on correctly formulating the algorithm, without being distracted by the detailed syntax of a computer programming language Chapter 11: Computer Programming Page 584

How do I figure out an algorithm? Chapter 11: Computer Programming Page 585

What’s the best way to express an algorithm? Structured English –limited selection of sentence structures that reflect processing activities Pseudocode – a mixture of English and your favorite programming language Flowcharts – a graphical representation of the way that a computer should progress from one instruction to the next Chapter 11: Computer Programming Page 587

Chapter 11: Computer Programming Page 588

How do I know if my algorithm is correct? Before finalizing the algorithm, perform a walkthrough to verify that your algorithm works Step through the problem using realistic test data Chapter 11: Computer Programming Page 589

How do I specify the order in which program instructions are performed by the computer? During sequential execution, the computer performs each instruction in the order it appears Normal pattern of program execution Print “This is the first line.” Print “This is the second line.” Chapter 11: Computer Programming Page 590

Is there an alternative to sequential execution? Chapter 11: Computer Programming Page 590

Can the computer make decisions while it executes a program? A selection control structure (decision structure or branch) tells a computer what to do, based on whether a condition is true or false Chapter 11: Computer Programming Page 592

Can a computer automatically repeat a series of instructions? A repetition control structure directs the computer to repeat one or more instructions until a certain condition is met Chapter 11: Computer Programming Page 593

What kinds of problems are best suited to the procedural approach? Problems that can be solved by following a step-by-step algorithm Transaction processing Characterized by the use of a single algorithm applied to many different sets of data Chapter 11: Computer Programming Page 596

What are the advantages and disadvantages of the procedural paradigm? Tends to produce programs that run quickly and use system resources efficiently Does not fit gracefully with certain types of problems Unstructured problems Complex algorithms Forces programmers to view problems as a series of steps Chapter 11: Computer Programming Page 596

Chapter 11 Computer Programming Section C: Object-Oriented Programming 面向对象程序设计 Computer Concepts 8th Edition

What is the basic focus of the object-oriented paradigm? Based on the idea that the solution for a problem can be visualized in terms of objects that interact with each other An object is a unit of data that represents an abstract or real-world entity Chapter 11: Computer Programming Page 597

What’s the difference between an object and a class? A class is a template for a group of objects with similar characteristics Chapter 11: Computer Programming Page 597

Inheritance: How flexible are classes for defining different types of objects? The object-oriented paradigm endows classes with quite a bit of flexibility An OO feature called “inheritance” provides flexibility to deal with objects’ unique characteristics Chapter 11: Computer Programming Page 599

What is inheritance? Inheritance refers to passing certain characteristics from one class to other classes The process of producing new classes with inherited attributes creates a superclass and subclasses Chapter 11: Computer Programming Page 599

Methods and Messages: How does an OO program use objects? Programs use objects to manipulate them with methods A method is a segment of code that defines an action Chapter 11: Computer Programming Page 600

What can a method do? Collect input Perform calculations Make comparisons Execute decisions Produce output Chapter 11: Computer Programming Page 600

What activates a method? A method is activated by a message, which is included as a line of program code, sometimes called a “call” Chapter 11: Computer Programming Page 601

How do methods relate to classes? Methods can be defined along with the class they affect Chapter 11: Computer Programming Page 601

What is polymorphism? The ability to redefine a method in a subclass Sometimes called overloading Chapter 11: Computer Programming Page 602

How does a Java program begin? Begins by locating a standard method called main() Contains code to send messages to objects by calling methods Chapter 11: Computer Programming Page 605

What happens when the completed program runs? Chapter 11: Computer Programming Page 606

How did object-oriented languages originate? Computer historians believe that SIMULA, developed in 1962, was the first computer language to work with objects, classes, inheritance, and methods The second major development in object-oriented languages came in 1972 when Alan Kaye began work on the Dynabook project Chapter 11: Computer Programming Page 606

Which object-oriented languages are popular today? Ada95 C++ Visual Basic C# Java Chapter 11: Computer Programming Page 606

What are the advantages and disadvantages of the OO paradigm? Programmers may be able to visualize the solutions to problems more easily Encapsulation allows objects to be adapted and reused in a variety of different programs OO programs tend to require more memory and processing resources than procedural programs Chapter 11: Computer Programming Page 607

Chapter 11 Computer Programming Section D: Declarative Programming Computer Concepts 8th Edition

What is a declarative paradigm? Attempts to describe a problem without specifying exactly how to arrive at a solution Chapter 11: Computer Programming Page 608

What is unique about the declarative paradigm? Describes aspects of a problem that lead to a solution Focuses on describing the problem Chapter 11: Computer Programming Page 608

What are the building blocks for the declarative paradigm? Use a collection of facts and rules to describe a problem A fact provides the computer with basic information for solving a problem Chapter 11: Computer Programming Page 608

How does a programmer plan a declarative program? The core of most declarative programs is a set of facts and rules that describe a problem A decision table is a tabular method for visualizing and specifying rules based on multiple factors Chapter 11: Computer Programming Page 609

Prolog Facts: How does a programmer code facts? An argument represents one of the main subjects that a fact describes The predicate describes the relationship between the arguments shapeof(pizza,round). Chapter 11: Computer Programming Page 609

What is a goal? Chapter 11: Computer Programming Page 611

What is instantiation? Chapter 11: Computer Programming Page 612

Prolog Rules: How does a programmer code Prolog rules? Chapter 11: Computer Programming Page 613

Does the order of rules affect the way a Prolog program works? The order or sequence of rules in a Prolog program is not critical Chapter 11: Computer Programming Page 615

What does a complete program look like in Prolog? Chapter 11: Computer Programming Page 616

Input Capabilities: How do I collect input from the user? Chapter 11: Computer Programming Page 617

How can I add facts at runtime? You can use Prolog’s built-in asserta predicate to temporarily add facts to the program asserta(priceof(pizza1,10)) Chapter 11: Computer Programming Page 617

Debugging with Trace: How do I test a Prolog program? Most Prolog compilers provide a trace feature that allows you to track through each instantiation Chapter 11: Computer Programming Page 618

What kinds of problems are suitable for the declarative approach? Databases that contain complex relationships Decision support systems that handle semi-structured problems Expert systems that require analysis of multiple, interrelated factors Chapter 11: Computer Programming Page 618

What are the advantages and disadvantages of declarative languages? Provide a great deal of flexibility for querying a set of facts and rules Not very popular and not widely used for production applications Provide minimal input and output capabilities Relatively poor performance on today’s personal computer architecture Chapter 11: Computer Programming Page 619

Conclusion You should now be able to: Describe the role of computer programmers and software engineers Categorize today’s popular computer programming languages by generation and paradigm Explain the process of planning, coding, and testing a computer program Describe the advantages and disadvantages of generic text editors, program editors, and VDEs for coding computer programs Define the term algorithm and describe how it relates to procedural programming Chapter 11: Computer Programming

Conclusion Identify various tools that programmers use to plan programs, such as flowcharts, structured English, pseudocode, UML diagrams, and decision tables Follow the control structures for a procedural program Describe the major concepts of object-oriented programming, such as objects, classes, inheritance, messages, methods, polymorphism, and encapsulation Create some basic facts and rules using Prolog syntax Describe how a declarative language, such as Prolog, satisfies goals by instantiation Chapter 11: Computer Programming