Software Development Basics PDF

Summary

This document provides an introduction to software development basics. It covers topics on programming, programming languages, and different programming concepts. The document also includes examples and flowcharts to better understand and explain those programming concepts.

Full Transcript

Software development basics Slide 1 of 58 What is Programming? ▪ Programming is giving a set of instructions to a computer to execute. Slide 2 of 58 Programming vs Coding ▪ While sometimes used interchangeably, programming and coding...

Software development basics Slide 1 of 58 What is Programming? ▪ Programming is giving a set of instructions to a computer to execute. Slide 2 of 58 Programming vs Coding ▪ While sometimes used interchangeably, programming and coding actually have different definitions. ▪ Programming is the mental process of thinking up instructions to give to a machine (like a computer). ▪ Coding is the process of transforming those ideas into a written language that a computer can understand. Slide 3 of 58 Programming All Programs Have in Common: Take data and manipulate it to produce a result Input – Process – Output o Input: from files, the keyboard, or other input device o Process: perform some operations on the input to get the required result. o Output: display or print the result using the monitor, printer, or other output device. Slide 4 of 58 Programming languages ▪ Programming languages is a system of notation for writing computer programs. They are used to best communicate with computers. ▪ Programming languages are either text-based or graphical. ▪ Programming has evolved from punch cards with rows of numbers that a machine read, to drag-and-drop interfaces that increase programming speed. Slide 5 of 58 Punch cards Slide 6 of 58 Drag-and-drop interfaces Slide 7 of 58 Programming Languages Machine language “Natural language” of computer component Machine dependent Assembly language English-like abbreviations represent computer operations Translator programs convert to machine language High-level language Allows for writing more “English-like” instructions Contains commonly used mathematical operations Slide 8 of 58 Translators Compiler Converts high-level language programs to machine language Example: C, C++, C# Interpreter Execute high-level language programs without compilation Example: Perl, Python and Matlab Assembler Converts Assembly language programs to machine language Example: GAS Slide 9 of 58 How do we solve a problem using a computer? Problem Software Design: choose algorithms and data structures Algorithm Programming: use language to express design Program Compiling/Interpreting: convert language to Instruction machine instructions Set Slide 10 of 58 10 Problem Solving Problem Statement stated using "natural language" may be ambiguous, imprecise Algorithm step-by-step procedure, guaranteed to finish definiteness, effective computability, finiteness Program A program is a collection of instructions. express the algorithm using a computer language high-level language, low-level language Slide 11 of 58 Problem Solving ▪ A program solves a problem by: Taking in data Manipulating the data Producing some information ▪ If you can break a problem down into these steps, you can create a program to solve it. ▪ But do we start writing code as soon as we run into a problem? Answer: No ! Slide 12 of 58 Program Development Cycle ▪ When Developing a program in the real world, there are seven steps: 1) Analyze the problem 2) Plan a solution 3) Design an interface 4) Write the code 5) Test and debug 6) Document the program 7) Maintain the program Slide 13 of 58 Analyze the Problem ▪ Understand what the problem is and what the solution should be ▪ Keep in mind what the End User should be able to see and do. User – Anyone who uses the program. End User – The person whom the program was designed for him/her to use. ▪ Also keep in mind what the CORRECT solution to the problem is. ▪ This needs to be done before ANY of the following steps can take place. Slide 14 of 58 Algorithms vs. Programs ▪ An Algorithm is a step-by-step procedure devised for the purpose of taking in data and producing the correct output. ▪ A program is the actual implementation of an algorithm in a programming language. ▪ Before writing a program, you must develop an algorithm to solve a problem. ▪ It is highly recommended to think about the problem first, then develop an algorithm, then write the program. Slide 15 of 58 Plan a Solution ▪ Once you understand the problem, you can develop an algorithm. ▪ Create precise steps for the entire flow of the program. Usually in the form of: ▪ Get Input ▪ Validate Input ▪ Manipulate Input ▪ Output Solution ▪ Every detail should be covered in the algorithm. ▪ Consider what is logical and illogical for the control flow. ▪ There are many tools programmers use to model the flow of a program. Slide 16 of 58 Modeling Tools To help understand the steps of an algorithm, programmers use a variety of tools: ▪ Pseudocode is a description of an algorithm using everyday wording, but molded to appear similar to a simplified programming language. ▪ Flowchart is a type of diagram that represents a workflow or process. A flowchart can also be defined as a diagrammatic representation of an algorithm, a step-by-step approach to solving a task. Slide 17 of 58 Flowchart symbols ▪ Terminal: is an oval that indicates the beginning and end of a program. It usually contains the words Start or End. ▪ Flowline: is a line from one symbol pointing towards another to show the process’s order of operation. This displays the flow of execution in a program. Slide 18 of 58 Flowchart symbols ▪ Input/Output: input/output is represented by a rhomboid and indicates the input or output of data. This is similar to setting a value to a variable. ▪ Process: represented by a rectangle, is an operation that manipulates data. Slide 19 of 58 Flowchart symbols ▪ Decision: represented by a rhombus and show a conditional operation that will determine which path a program should take. This is similar to conditional statements which control the flow of execution in a program. ▪ Connector: Used to join flow lines. Slide 20 of 58 Three Basic Constructs Slide 21 of 58 Flowcharts for three constructs Slide 22 of 58 Three Basic Constructs ▪ There are three basic ways to decompose a task: Slide 23 of 58 Sequential ▪ Do Subtask 1 to completion, then do Subtask 2 to completion, etc Slide 24 of 58 Sequential ▪ Example 1: Write an algorithm and draw a flowchart to convert the length in feet to centimeter. ▪ Length in cm= length in feet * 30.48 Slide 25 of 58 Sequential ▪ Example 1: ▪ Pseudocode: Input the length in feet (Lft) Calculate the length in cm (Lcm) by multiplying LFT with 30.48 Print length in cm (LCM) ▪ Algorithm: Step 1: Input Lft Step 2: Lcm  Lft x 30.48 Step 3: Print Lcm Slide 26 of 58 Sequential ▪ Example 1: Start ▪ Flowchart: Input Lft Lcm  Lft x 30.48 Print Lcm End Slide 27 of 58 Sequential ▪ Example2: Write an algorithm and draw a flowchart that will read the two sides of a rectangle and calculate its area. ▪ Rectangle area = length * width Slide 28 of 58 Sequential ▪ Example 2: ▪ Pseudocode: Input the width (W) and Length (L) of a rectangle Calculate the area (A) by multiplying L with W Print A ▪ Algorithm: Step 1: Input W,L Step 2: A = L * W Step 3: Print A Slide 29 of 58 Sequential ▪ Example 2: Start ▪ Flowchart: Input W, L ALxW Print A End Slide 30 of 58 Sequential ▪ Example 3: Consider the problem of finding out how many stamps you need to put on an envelope to mail it. ▪ The rule here is that you need 1 stamp for every 5 sheets of paper in the envelope. ▪ So, the algorithm looks something like this: ▪ Get the number of sheets from the user. (Input) ▪ Divide the number of sheets by 5 (Process) ▪ Round the result from step 2 the highest whole number (Process) ▪ Output the number of stamps (Output) Slide 31 of 58 Sequential ▪ Example 3: ▪ So, a specific example looks like ▪ The user inputs 16 sheets of paper ▪ Dividing 16 by 5 results in 3.2 ▪ Rounding 3.2 up results in 4 ▪ Output 4 stamps Slide 32 of 58 Sequential ▪ Example 3: Start ▪ Flowchart: Read sheets Set stamps = sheets / 5 Round stamps up to next whole number Display: "You will need: " stamps Slide 33 of 58 End Sequential ▪ Example 3: ▪ What could go wrong? ▪ What if the user inputs “Banana” sheets of paper? Slide 34 of 58 Conditional/ Decision ▪ If condition is true, do Subtask 1; else, do Subtask 2. Slide 35 of 58 Conditional/ Decision ▪ The expression A>B is a logical expression. ▪ it describes a condition we want to test. Yes No ▪ if A>B is true (if A is greater than B) we A>B take the action on left. ▪ print the value of A Print A Print B ▪ if A>B is false (if A is not greater than B) we take the action on right ▪ print the value of B Slide 36 of 58 If–then–else Structure ▪ The structure is as follows: If condition then true alternative else false alternative endif Slide 37 of 58 If–then–else Structure ▪ The algorithm for the flowchart is as follows: Yes No A>B If A>B then Print A Print A Print B else Print B endif Slide 38 of 58 Relational Operators Slide 39 of 58 Conditional/ Decision ▪ Example 3: Stamp problem (Revised Algorithm) ▪ Get the number of sheets from the user. (Input) ▪ Check to see if the input is a positive number. (Validate) ▪ Divide the number of sheets by 5 (Process) ▪ Round the result from step 2 the highest whole number (Process) ▪ Output the number of stamps (Output) Slide 40 of 58 Conditional/ Decision Start Read sheets Yes Is sheets No positive number? Set stamps = sheets / 5 Display error Round stamps up to next message whole number Display: "You will need: " stamps Slide 41 of 58 End Conditional/ Decision ▪ Example 4: Create an algorithm and a flowchart that will read two numbers and then display the bigger number. Slide 42 of 58 Conditional/ Decision ▪ Example 4: ▪ Algorithm: 1. Input number1, number2 2. If (number1 > number2) then MAX = number1 Else MAX = number2 Endif 3. Print “The largest value is”, MAX Slide 43 of 58 Conditional/ Decision ▪ Example 4: Start ▪ Flowchart: Input number1, number2 Yes No number1>number2 MAX number1 MAX number2 Print “The largest value is”, MAX End Slide 44 of 58 Conditional/ Decision ▪ Example 5: Create an algorithm and a flowchart that will accept a student mark and then display “PASS” if the mark is 50 or more and display “FAIL” otherwise. Slide 45 of 58 Conditional/ Decision ▪ Example 5: ▪ Algorithm: 1. Input mark 2. If (mark >= 50) then Print “PASS” Else Print “FAIL” Endif Slide 46 of 58 Conditional/ Decision ▪ Example 5: Start ▪ Flowchart: Input mark Yes No mark >= 50 Print “PASS” Print “FAIL” End Slide 47 of 58 Repetition ▪ Do Subtask over and over, as long as the test condition is true. Slide 48 of 58 Repetition ▪ Example 6: Write an algorithm and draw a flowchart to find the sum of numbers from 1 to 10. ▪ 1+2+3+4+5+6+7+8+9+10 Slide 49 of 58 Repetition ▪ Example 6: ▪ Algorithm: Step 1: Set sum to 0, number to 1 Step 2: update sum as sum = sum + number Step 3: increment number Step 4: Repeat steps 2 and 3 until number = 10 Step 5: Print sum Slide 50 of 58 Repetition ▪ Example 6: Start ▪ Flowchart: Set sum = 0 Set number = 1 No number Equal == Slide 57 of 58 Logical operators Logical And Or Not Slide 58 of 58

Use Quizgecko on...
Browser
Browser