Programming Process The programmer’s job can be broken down into six programming steps: Understand the problem Plan the logic Code the program Translate.

Slides:



Advertisements
Similar presentations
CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
Advertisements

ITEC113 Algorithms and Programming Techniques
Chapter 2- Visual Basic Schneider
CIS105 Chapter 1 Theory Review. Page 2 Hardware and Software are the two major components o any computer system Hardware is the set of physical devices.
An Overview of Computers and Logic
An Overview of Programming Logic and Design
Program Development and Programming Languages
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
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.
Chapter 2: Algorithm Discovery and Design
Chapter 3 Planning Your Solution
Programming Logic and Design Fourth Edition, Introductory
The Program Design Phases
An Overview of Computers and Programming
Review Algorithm Analysis Problem Solving Space Complexity
PRE-PROGRAMMING PHASE
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
Programming Logic and Design Fifth Edition, Comprehensive
DCT 1123 Problem Solving & Algorithms
An Overview of Computers and Logic
Programming Logic and Design Sixth Edition Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs.
ICT Introduction to Programming
CIS Computer Programming Logic
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step.
PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.
1 Introduction to Flowcharting. 2 Writing a program Defining the problem –Write down what the program will do Planning –Write down the steps, draw a flowchart.
Programming Concepts Chapter 3.
Input, Output, and Processing
Describe the Program Development Cycle. Program Development Cycle The program development cycle is a series of steps programmers use to build computer.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Software Life Cycle What Requirements Gathering, Problem definition
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.
BACS 287 Programming Logic 1. BACS 287 Programming Basics There are 3 general approaches to writing programs – Unstructured – Structured – Object-oriented.
P ROGRAMMING L OGIC AND D ESIGN S IXTH E DITION Chapter 1 An Overview of Computers and Programming.
An Object-Oriented Approach to Programming Logic and Design Chapter 1 An Overview of Computers and Logic.
Flowcharts. Problem Solving Computer programs are written to solve problems or perform tasks Programmers translate the solutions or tasks into a language.
Visual Basic Programming
ALGORITHM List of instructions for carrying out some process step by step. A sequence of instructions which has a clear meaning and can performed with.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Algorithms & Flowchart
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Dale Roberts 1 Program Control - Algorithms Department of Computer and Information Science, School of Science, IUPUI CSCI N305.
Program Design BUILDING A HOUSE. Steps to Designing a Program 1. Define the Output 2. Develop the logic to get that output 3. Write the program.
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
1 Program Planning and Design Important stages before actual program is written.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
2 Chapter 21 Understanding Structure Programming Logic and Design, Second Edition, Comprehensive 2.
Programming Logic and Design Seventh Edition
CSE 110: Programming Language I Matin Saad Abdullah UB 404.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
ALGORITHMS AND FLOWCHARTS
Computer Programming.
DDC 1023 – Programming Technique
Chapter 2- Visual Basic Schneider
The Selection Structure
Algorithms An algorithm is a sequence of steps written in the form of English phrases that specific the tasks that are performed while solving the problem.It.
A Beginner’s Guide to Programming Logic, Introductory
Designing and Debugging Batch and Interactive COBOL Programs
Unit# 9: Computer Program Development
MSIS 655 Advanced Business Applications Programming
Structured Program
Chapter 2- Visual Basic Schneider
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Chapter 2- Visual Basic Schneider
Programming Logic and Design Eighth Edition
Structural Program Development: If, If-Else
Presentation transcript:

Programming Process The programmer’s job can be broken down into six programming steps: Understand the problem Plan the logic Code the program Translate the program into machine language Test the program Put the program into production

Understand the Problem Programmers must first understand what it is the user wants To understand the problem, you must analyze it Really understanding the problem may be one of the most difficult aspects of programming The description of what the user needs may be vague The user may not even really know what he or she wants Users who think they know what they want frequently change their minds after seeing sample output

Understand the Problem Analysis & Really Understanding Example To invite some people, I need the list of people who work during five more years. Definite problem or ambiguous problem ?

Understand the Problem Analysis & Really Understanding Example To invite some people, I need the list of people who work during five more years. Definite problem or ambiguous problem ? Ambiguous problem Full-time or part-time worker or both of them ? Regular employee or contract employee ? Which type of list ? A good programmer is often part counselor, part detective

Programming Process The programmer’s job can be broken down into six programming steps: Understand the problem Plan the logic Code the program Translate the program into machine language Test the program Put the program into production

Plan the Logic Programmer plans the steps to the program, deciding what steps to include and how to order them Example Planning tour Planning party The two most common tools flowcharts : pictorial representation Pseudocode : English-like representation

Plan the Logic Flowcharts A pictorial representation of the logical steps it takes to solve a problem. Uses Standardized Symbols Utilize Formula Notation Typically Read from Top to Bottom or from Left to Right on a Page

Plan the Logic Basic flowchart symbols Start/Stop (Terminator) Process (Rectangle) Input/Output (Parallelogram) Decision (Diamond) Connector (Circle) Flowlines (Arrows) Predefined Process (Rectangle)

Sequence, Selection, Repetition entrance entrance entrance exit exit exit

Plan the Logic Pseudocode An English-like representation of the logical steps it takes to solve a problem pseudo – a prefix that means false Short English-Like Statements Not Standardized Proper use of indentation Example start get InputNumber compute calculatedAnswer as InputNumber times 2 print calculatedAnswer stop

Programming Process The programmer’s job can be broken down into six programming steps: Understand the problem Plan the logic Code the program Translate the program into machine language Test the program Put the program into production

Code the program Writing the program in one of more than 400 programming languages Pascal, Fortran, C, C++, Java….. Concentrate on the syntax of the language Exact instruction, symbol, …. ? Some very experienced programmers successfully combining the logic planning and the actual instruction writing, or coding of the program, in one step Writing a post card Writing a cinema scenario

Code the program Which is harder: Planning the Logic or Coding the Program? Example Planning the logic :Planning mystery novel Coding the program : Writing English or Spanish based on the original scenario. Who gets more annual salary ?

Programming Process The programmer’s job can be broken down into six programming steps: Understand the problem Plan the logic Code the program Translate the program into machine language Test the program Put the program into production

Translate the Program Objective Need to compiler or interpreter Each computer knows only one language, Machine Language. High-level Languages must be translated into Machine Language Need to compiler or interpreter Compiler catches every syntax error. When writing a program, a programmer might need to recompile the code several times An executable program is created only when the code is free of syntax errors

Translate the Program Creating an executable program

Programming Process The programmer’s job can be broken down into six programming steps: Understand the problem Plan the logic Code the program Translate the program into machine language Test the program Put the program into production

Test the Program Why does it need to be tested ? Test Example Syntax Errors : by compile Logical Errors : by test Test Executing the program with some sample data Seeing whether or not the results are logically correct. being tested with many sets of data carefully Example Logically incorrect start get InputNumber compute calculatedAnswer as InputNumber times 20 print calculatedAnswer stop

Programming Process The programmer’s job can be broken down into six programming steps: Understand the problem Plan the logic Code the program Translate the program into machine language Test the program Put the program into production

Put the program into the production Once the program is tested adequately, it is ready for the organization to use. Putting the program into production might mean simply running the program once if it was written to satisfy a user’s request for a special list.

Flowchart & Pseudocode Flowcharts (pictorial representations) and pseudocode (English-like representations) are used by programmers to plan the logical steps for solving a programming problem Some professional programmers prefer writing pseudocode to drawing flowcharts, because using pseudocode is more similar to writing final statements in programming language

Flowchart & Pseudocode Almost every program involves the steps of input, processing, and output, necessitating some graphical way to separate them Arithmetic operation statements are examples of processing in a flowchart, where you use a rectangle as the processing symbol containing a processing statement

Flowchart & Pseudocode To represent an output statement, you use the parallelogram, which is also the same symbol used for input statements

Flowchart & Pseudocode In flowcharts: Arrows, or flowlines, connect and show the appropriate sequence of steps A terminal symbol, or start/stop symbol, should be included at each end Often, “start” or “begin” is used as the first terminal symbol and “end” or “stop” is used in the other The standard terminal symbol is shaped like a racetrack; often called a lozenge, because it resembles the shape of a medicated candy lozenge you might use to soothe a sore throat Flowlines (Arrows) Start/Stop (Terminator)

Flowchart & Pseudocode Complete flowchart for the program that doubles a number, and the pseudocode for the same problem start get InputNumber compute calculatedAnswer as InputNumber times 2 print calculatedAnswer stop

Naming Variables Variables Example memory locations, whose contents can vary or differ over time. reasonable and descriptive variable names Example InputNumber caluculatedAnswer start get InputNumber compute calculatedAnswer as InputNumber times 2 print calculatedAnswer stop

Naming Variables Naming Rules Every programming language has its own set of rules for naming variables. most languages allow both letters and digits : a,b,c, 1,2,3 some languages allow hyphens and/or underscores : - _ some allow dollar signs or other special characters : $, #, @ some allow for foreign characters : Japanese, Spanish different languages put different limits on lengths some languages are case sensitive, others are not : name, Name in general, variable names may not begin with a digit : name1

Naming Variables Textbook Conventions – two rules: (1) Variable names must be one word can contain letters, digits, hyphens, underscores, with the exception of spaces. (2) Variable names should have some appropriate meaning Undesirable : G, u84, fred, mike, richard, pink, Desirable : rate, name, age, count, score, index, lastName employeeLastName, 5employeeLastName, employeeLast, empLast, emlstnam, lastNameofTheEmployeeInQuestion, last name (x), employeelastname,

Naming Variables Assignment values to variables Whatever operation is performed to the right of the equal sign results in a value that is placed in the memory location to the left of the equal sign. compute calculatedAnswer as InputNumber times 2 is the same as calculatedAnswer = InputNumber * 2

Naming Variables Constant Variables A memory location, similar to a variable, except its value never changes during a program. taxRate = .0825 Pi = 3.141592 Variables memory locations, whose contents can vary or differ over time.

Naming Variables Data Types – two basic types Character Numeric Character : ‘a’ ‘b’ ‘c’ ‘d’ ‘e’ Character string : “Richard” “Michale” Numeric Integer : …, -3, -2, -1, 0, 1, 2, 3, …. Floating-Point : …, -2.0, -1.5, -1, -0.5, 0, 0.5, 1.0, ….

calculatedAnswer=InputNumber*2 Ending a Program Infinite loop start get InputNumber compute calculatedAnswer as InputNumber times 2 print calculatedAnswer ……… stop start get InputNumber calculatedAnswer=InputNumber*2 Print calculatedAnswer

Ending a Program An infinite loop is a repeating flow of logic with no end To end the program, set a predetermined value for inputNumber that means “Stop the program!” The program can then test any incoming value for inputNumber and, if it is a 0, stop the program Testing a value is also called making a decision Represented in flowchart by diamond shape called a decision symbol

Ending a Program Decision symbol start start get InputNumber get Yes inputNumber = 0 ? inputNumber = 0 ? stop No calculatedAnswer=InputNumber*2 calculatedAnswer=InputNumber*2 Print calculatedAnswer Print calculatedAnswer

Ending a Program Dummy value A pre-selected value that stops the execution of a program is often called a dummy value since it does not represent real data, but just a signal to stop Sometimes, such a value is called a sentinel value because it represents an entry or exit point, like a sentinel who guards a fortress

Using a Connector If a flowchart has six processing steps and a page provides room for only three, you might represent the logic as shown below: On-page connector symbol Off-page connector symbol

Evolution of Programming Technique Currently, there are two major techniques used to develop programs and their procedures Procedural programming focuses on the procedures that programmers create Object-oriented programming, focuses on objects, or “things”, and describes their features, or attributes, and their behaviors

Summary A programmer’s job involves six steps: Understanding the problem Planning the logic Coding the problem Translating the program into machine language Testing the program Putting the program into production When programmers plan the logic for a solution to a programming problem, they often use flowcharts or pseudocode

Summary Testing a value involves making a decision Most programming languages use the equal sign to assign values to variables Procedural and object-oriented programmers approach program problems differently