300 likes | 681 Views
Objectives. Learning about Programming Describe the steps involved in the programming process Understand how to use flowchart Use Sentinel value to end a program Use a connector symbol Describe data types. Learning about Programming.
E N D
Objectives • Learning about Programming • Describe the steps involved in the programming process • Understand how to use flowchart • Use Sentinel value to end a program • Use a connector symbol • Describe data types
Learning about Programming • Program is a set of instructions that you write to tell a computer what to do • A computer language has rules governing its word usage and punctuation • These rules are called syntax • Every computer operates on circuitry that consists of millions of on-off (0 and 1) switches (binary system) • Data from “Star trek” speaks the machine (binary) language.
Learning about programming • Each programming language uses a piece of software to translate the specific programming language into the computer’s on-off circuitry language (machine language) • The language translation software is called a compiler (or translator). All instructions converted at once from high-level language to machine language. • Syntax errors are relatively easy to locate and correct
The instruction “ADD 2 and 5 and assign the result to variable y” written in different programming languages
Learning about programming • For each program to work properly, you must give the instructions to the computer in a specific sequence, you must not leave any instructions out, and you must not add extraneous instructions • By doing this, you are developing the logic of the computer program • Once instructions have been inputted into the computer and translated into machine language, a program can be run or executed
Understanding the Programming Process • A programmer’s job involves writing instructions, and can be broken down into six programming steps: • Understand the problem (analysis and design 1) • Plan the logic (analysis and design 2) • Code the program • Translate the program into machine language • Test the program • Put the program into production
Understand the Problem • Professional computer programmers write programs to satisfy the needs of users • Because programmers are providing a service to users, programmers must first understand what the users want • Understanding of business problems • Computer Science vs. MIS
Plan the Logic • The heart of the programming process lies in planning the program’s logic • During this phase of the programming process, the programmer plans the steps to the program, deciding what steps to include and how to order them • The programmer doesn’t worry about the syntax of any particular language at this point, just about figuring out what sequence of events will lead from the available input to the desired output
5 4 3 COSTS 2 1 0 RELATIVE COSTS OF REPAIRING ERRORS(BASED ON CONSULTANT REPORTS & TRADE LITERATURE) ANALYSIS AND DESIGN POSTIMPLELENTATION CONVERSION PROGRAMMING
Code the Program • Some very experienced programmers can successfully combine the logic planning and the actual instruction writing, or coding of the program, in one step • This may work for planning and writing a very simple program, just as you can plan and write a postcard to a friend using one step • The planning step is actually more difficult than the spelling and grammar rules you must learn
Translate the Program into Machine Language • Languages like Java are available for programmers to use because someone has written a translator program (a compiler or interpreter) that changes the English-like high-level language in which the programmer writes into the low-level machine language that the computer understands
Test the Program • A program that is free of syntax errors is not necessarily free of logical errors • Once a program is free from syntax errors, the programmer can test it—that is, execute it with some sample data to see whether or not the results are logically correct • Programs should be tested with many sets of data
Put the Program into Production • Once the program is tested adequately, it is ready for the organization to use • However, the process might take months if the program will be run on a regular basis, or if it is one of a large system of programs being developed • Conversion, the entire set of actions an organization must take to switch over to using a new program or set of programs, can sometimes take months or years to accomplish
Inherent Problems • Uneven and thin spread application domain knowledge amongst developers • Rare utilization of existing code (program) • Users requirements can be fluctuated and conflicted • Easy breakdown of communication and coordination • Difficult to manage project scheduling – typical scheduling techniques such as (PERT/CPM)does not work properly in programming world
Using Flowchart Symbols • When programmers plan the logic for a solution to a programming problem, they often use one of two tools, flowcharts or pseudocode • A flowchart is a pictorial representation of the logical steps it takes to solve a problem – beginners • Pseudocode (“sue-dough-code”) is an English-like representation of the same thing – experts • Using pseudocode involves writing down all the steps you will use in a program (more similar to writing the final statements in the programming language)
Using Flowchart Symbols • To show the correct sequence of these statements, you use arrows, or flowlines, to connect the steps
Ending a Program by Using Sentinel Values • The diamond symbol usually contains a two mutually exclusive answers like yes and no or true and false or value zero to stop the program • A preselected value that stops the execution of a program is often called a dummy value because 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 that guards a fortress • Many programming languages use the term eof (for “end of file”) to stop the program
Flowchart for Number-Doubling Program with Sentinel Value of Zero
Using the Connector • By using just the input, processing, output, decision, and terminal symbols, you can represent the logic for many diverse applications • Only one other symbol needed for a flow chart is the connector • A connector will be used when limited page size forces you to continue the flowchart on the following page
Flowcharting Example • Draw a flowchart of your preparation to go to work or school in the morning. • Include at least two decisions and two loops. Example figure
Understanding Data Types • Computers deal with two basic types of data—character and numeric • When you use a specific number value, like 43, within a program, you write it using the digits and no quotation marks • A specific numeric value is often called a numeric constant, because it does not change • When you use a specific character value, or string of characters, like “Chris,” you enclose the string or character constant within quotation marks
Understanding Data Types • Similarly, most computer languages allow at least two distinct types of variables • One type of variable can hold a number and is often called a numeric variable • Most programming languages have a separate type of variable that can hold letters of the alphabet and other special characters such as punctuation marks • Depending on the language, these variables are called character, text, or string variables
Understanding Data Types • Some languages have different rules for naming the variables, but with others you must include a simple statement (called a declaration) telling the computer which type of data to expect • Some languages allow for several types of numeric data • Languages like Pascal, C++, C#, and Java distinguish between integer or whole number variables, and floating-point or fractional numeric variables that contain a decimal point
Summary • You write computer instructions in a computer programming language that requires specific syntax • A programmer’s job involves understanding the problem, planning the logic, coding the program, translating the program into machine language, testing the program, and putting the program into production • When programmers plan the logic for a solution to a programming problem, they often use flowcharts or pseudocode
Summary • You represent a decision in a flowchart by drawing a diamond-shaped decision symbol which contains a question • A circular connector symbol is used to continue a flowchart that does not fit on a single page • Most programming languages allow the equal sign to assign values to variables • Programmers must distinguish between numeric and character variables because computers handle the two types of data differently • A variable declaration tells the computer which type of data to expect