11 Computer Programming Section A Programming Basics CHAPTER

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.
Lecture 1: Overview of Computers & Programming
Computers Are Your Future
Programming Creating programs that run on your PC
Introduction To System Analysis and Design
Computer Concepts 5th Edition Parsons/Oja Page 546 CHAPTER 11 Software Engineering Section A PARSONS/OJA Computer Programming.
Computers: Tools for an Information Age
Java Programming, 3e Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
Chapter 16 Programming and Languages: Telling the Computer What to Do.
Your Interactive Guide to the Digital World Discovering Computers 2012 Chapter 13 Computer Programs and Programming Languages.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
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.
Copyright © 2001 by Wiley. All rights reserved. Chapter 1: Introduction to Programming and Visual Basic Computer Operations What is Programming? OOED Programming.
Your Interactive Guide to the Digital World Discovering Computers 2012.
Computer Programming and Database Handout
Chapter 1 Introduction to Computers and C++ Programming.
CS102 Introduction to Computer 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.
Java Programming, 2E Introductory Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
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.
A First Program Using C#
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.
信息处理技术.
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.
CHAPTER ONE Problem Solving and the Object- Oriented Paradigm.
Introduction To System Analysis and Design
CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do.
Computer Concepts 2014 Chapter 12 Computer Programming.
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.
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.
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.
What is Programming? A program is a list of instructions that is executed by a computer to accomplish a particular task. Creating those instructions is.
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.
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.
Welcome to OBJECT ORIENTED PROGRAMMING Prepared By Prepared By : VINAY ALEXANDER PGT(CS) KV jhagrakhand.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Chapter 1: Introduction to Computers and Programming.
Software Engineering Algorithms, Compilers, & Lifecycle.
PROGRAMMING (1) LECTURE # 1 Programming and Languages: Telling the Computer What to Do.
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)
and Program Development
Tonga Institute of Higher Education IT 141: Information Systems
Tonga Institute of Higher Education IT 141: Information Systems
Presentation transcript:

11 Computer Programming Section A Programming Basics CHAPTER PARSONS/OJA Computer Programming Page 546

Programming Basics Section A 11 What is a computer program? Chapter 11 What is a computer program? 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 Page 548-549

Programming Basics Section A 11 What is a computer program? Chapter Page 548

Programming Basics Section A 11 How big is a typical computer program? Chapter 11 How big is a typical computer program? A small-sized program has fewer than 100,000 lines of code A medium-sized program has between 100,000 and 1 million lines A large program has more than 1 million lines of code On average, one person can write, test, and document only 20 lines of code per day Page 549

Programming Basics Section A 11 Who creates computer programs? Chapter 11 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 computer programs Page 549

Programming Basics Section A 11 Chapter 11 How does software engineering differ from computer programming? Software engineering refers to a program development process in which mathematical, engineering, and management techniques are applied to reduce the cost and complexity of a computer program while increasing its reliability and modifiability A software engineer design, codes, tests, and documents software, but tends to focus on designing and testing activities Page 549

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

Programming Basics Section A 11 Chapter 11 How are programming languages categorized? Low-level languages vs. high-level languages Generation Paradigm Page 550

Programming Basics Section A 11 What is a low-level language? Chapter 11 What is a low-level language? A low-level language typically includes commands that are specific to a particular CPU or microprocessor family Includes machine languages and assembly languages Page 550

Programming Basics Section A 11 What is a high-level language? Chapter 11 What is a high-level language? 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 Page 550

Programming Basics Section A 11 What is a high-level language? Chapter Page 551

Programming Basics Section A 11 Chapter 11 What was the first generation of computer 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 Page 551

Programming Basics Section A 11 What is a second-generation language? Chapter 11 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 Assembly languages are most often used to write system software Page 551

Programming Basics Section A 11 What is a third-generation language? Chapter 11 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 Page 551-552

Programming Basics Section A 11 What is a fourth-generation language? Chapter 11 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 Page 552

Programming Basics Section A 11 What is a fourth-generation language? Chapter 11 What is a fourth-generation language? Page 552

Programming Basics Section A 11 Chapter 11 Do any fifth-generation languages exist? 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 Page 552

Programming Basics Section A 11 What is a programming paradigm? Chapter 11 What is a programming paradigm? The phrase programming paradigm refers to a way of conceptualizing and structuring the tasks that a computer performs Multiparadigm languages support more than one paradigm Page 553

Programming Basics Section A 11 What is a problem statement? Chapter 11 What is a problem statement? 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 Page 554

Programming Basics Section A 11 Chapter 11 Program Coding: How do I code a computer program? It depends on the programming language you use, the programming tools that you selected, and then programming paradigm that best fits the problem you’re trying to solve Page 555

Programming Basics Section A 11 What is a generic text editor? Chapter 11 What is a generic text editor? A generic text editor is any word processor that can be used for basic text editing tasks, such as writing e-mail, creating documents, or coding computer programs Click to start Page 555-556

Programming Basics Section A 11 What is a program editor? Chapter 11 What is a program editor? A program editor is a type of text editor specially designed for entering code for computer programs Page 556

Programming Basics Section A 11 What is a VDE? Chapter 11 What is a VDE? A VDE (visual development environment) provides programmers with tools to build substantial sections of a program by pointing and clicking Form Design Grid Control Properties Event Event-handling code Page 557

Programming Basics Section A 11 What is a VDE? Click to start Chapter Page 557

Section A Programming Basics Chapter 11 What is a VDE? Page 558

Programming Basics Section A 11 Chapter 11 Is a visual development environment better than an editor? It depends on whether a visual development environment is available for a specific programming language VDEs are not available for every programming language Microsoft Visual Basic was one of the first programming languages to feature a visual development environment Event-driven paradigm Page 558

Programming Basics Section A 11 Chapter 11 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 Page 559

Programming Basics Section A 11 What can cause program errors? Chapter 11 What can cause program errors? A syntax error occurs when an instruction does not follow the syntax rules, or grammar, of the programming language Omitting . misspelling a keyword A runtime error occurs when the computer can’t execute an instruction Divide by 0 A logic error is an error in the logic or design of a program Incorrect formula Page 559

Programming Basics Section A 11 How do programmers find errors? Chapter 11 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 Page 559

Programming Basics Section A 11 Chapter 11 Do computer programs contain any special documentation? User manuals Help files Programmers also insert remarks, which indicate how the code in a program works, in case others must modify the program Page 560

11 Computer Programming Section B Procedural Programming CHAPTER PARSONS/OJA Computer Programming Page 562

Procedural Programming Section B Procedural Programming Chapter 11 Algorithms: What is an algorithm? An algorithm is a set of steps for carrying out a task, which can be written down and implemented Carefully following the steps of a correctly formulated algorithm guarantees that you can accomplish the task for which the algorithm was designed Page 562

Procedural Programming Section B Procedural Programming Chapter 11 How do I write an algorithm? Typically 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 Page 562

Procedural Programming Section B Procedural Programming Chapter 11 How do I figure out an algorithm? Record the steps you take to solve the problem yourself The algorithm should: Specify how the computer gets initial information Specify how to manipulate this information Specify how the computer decides what to display as the solution Page 563-564

Procedural Programming Section B Procedural Programming Chapter 11 What’s the best way to express an algorithm? Structured English – a subset of the English language with a limited selection of sentence structures that reflect processing activities Pseudocode – a notation system for algorithms that has been described as “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 when it performs a task Page 565

Procedural Programming Section B Procedural Programming Chapter 11 What’s the best way to express an algorithm? Click to start Page 566

Procedural Programming Section B Procedural Programming Chapter 11 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 Page 567

Procedural Programming Section B Procedural Programming Chapter 11 Procedural Languages and Applications: What are the most popular procedural languages? COBOL FORTH APL ALGOL PL/1 Pascal C Ada BASIC Page 573

Procedural Programming Section B Procedural Programming Chapter 11 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 Page 574

Procedural Programming Section B Procedural Programming Chapter 11 What are the advantages and disadvantages of the procedural paradigm? This approach 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 Page 574

11 Computer Programming Section C Object-Oriented Programming CHAPTER PARSONS/OJA Computer Programming Page 575

Object-Oriented Programming Section C Object-Oriented Programming Chapter 11 What is the basic focus of the object-oriented paradigm? The object-oriented paradigm is 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, such as a person, place, or thing Page 575

Object-Oriented Programming Section C Object-Oriented Programming Chapter 11 What’s the difference between an object and a class? A class is a template for a group of objects with similar characteristics CLASS: Pizza Page 575

Object-Oriented Programming Section C Object-Oriented Programming Chapter 11 How do I define the classes that I need to solve a problem? A class attributes defines the characteristics of a set of objects A public attribute is available for use by any routine in the program A private attribute can be accessed only from the routine in which it is defined UML diagrams help plan the classes for a program Page 576

Object-Oriented Programming Section C Object-Oriented Programming Chapter 11 How do I define the classes that I need to solve a problem? Page 576

Object-Oriented Programming Section C Object-Oriented Programming Chapter 11 How do I code a class when writing a program? class Pizza { public string pizzaShape; public double pizzaPrice; public double pizzaSize; } Page 577

Object-Oriented Programming Section C Object-Oriented Programming Chapter 11 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 Page 577

Object-Oriented Programming Section C Object-Oriented Programming Chapter 11 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 Page 577

Object-Oriented Programming Section C Object-Oriented Programming Chapter 11 How do I code a subclass? Java uses the “extends” command to link a subclass to a superclass class RectanglePizza extends Pizza { double pizzaLength; double pizzaWidth; } Page 578

Object-Oriented Programming Section C Object-Oriented Programming Chapter 11 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 Collect input Perform calculations Make comparisons Execute decisions Produce output Page 578

Object-Oriented Programming Section C Object-Oriented Programming Chapter 11 How does a method look when it has been coded in Java? Page 578

Object-Oriented Programming Section C Object-Oriented Programming Chapter 11 What activates a method? A method is activated by a message, which is included as a line of program code, sometimes called a “call” Page 579

Object-Oriented Programming Section C Object-Oriented Programming Chapter 11 How do methods relate to classes? Methods can be defined along with the class they affect Page 579

Object-Oriented Programming Section C Object-Oriented Programming Chapter 11 What is polymorphism? Polymorphism, sometimes called “overloading,” is the ability to redefine a method in a subclass Page 580

Object-Oriented Programming Section C Object-Oriented Programming Chapter 11 What are the advantages of polymorphism? Provides OO programs with easy extensibility and can help simplify program code Page 581

Object-Oriented Programming Section C Object-Oriented Programming Chapter 11 How does a Java program begin? The computer begins executing a Java program by locating a standard method called main(), which contains code to send messages to objects by calling methods Page 583

Object-Oriented Programming Section C Object-Oriented Programming Chapter 11 How does a Java program begin? Page 583

Object-Oriented Programming Section C Object-Oriented Programming Chapter 11 What happens when the completed program runs? Click to start Page 584

Object-Oriented Programming Section C Object-Oriented Programming Chapter 11 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 Page 584

Object-Oriented Programming Section C Object-Oriented Programming Chapter 11 Which object-oriented languages are popular today? Ada95 C++ Visual Basic C# Java Page 584-585

Object-Oriented Programming Section C Object-Oriented Programming Chapter 11 What kinds of applications are suitable for object-oriented languages? If you can envision a problem as a set of objects that pass messages back and forth, the problem is suitable for the OO approach Page 585

Object-Oriented Programming Section C Object-Oriented Programming Chapter 11 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 Encapsulation refers to the process of hiding the internal details of objects and their methods OO programs tend to require more memory and processing resources than procedural programs Page 585