The Programming Process Define the problem* Make or buy software? Design the program * Code (write) the program Test (debug) the program Document the program *
Define the Problem What do you want to solve? What is the objective? What is the question?
Define the Problem You need: Clear, specific statement of goal Expected output Expected input
Define the Problem You need to know: Constraints? Special conditions? Make a plan
Documentation improve readability you remember others understand maintenance
Design a Solution break the problem into smaller parts break subproblems into smaller solvable components do other solutions exist? pros and cons of each solution solve each subproblem integrate the solutions to the subproblems to solve the original problem * * * * *
Structured Programming Not one giant step Many small tasks Programmer concentrate on details Usually done in teams
Structured Programming Reduces time (and $) Different modules Errors isolated Design written in code
Introduction Dumb Machines Algorithms pseudocode structure charts flowcharts
PSEUDOCODE Logical steps Written in English Indenting for logical structures begin game display instructions pick a number between 1 and 100 repeat turn until number is guessed or seven turns are completed input guess from user respond to guess end repeat end game display end message
Flowchart Logical steps represented by standard symbols display instructions get number is number even? YesNo continue *
Test the Design Does it solve our problem? no- select another design - return to the analysis of the problem yes- move on
NO plan, NO help Implement the Design Lease creative part Choose a language Choose a language Write the code Write the code NO plan, NO help *
Design Example Linear Search Problem: Find the largest number in a list * Algorithm: call the 1 st is the largest call the 2 nd current (cont.)
Design Example Linear Search 1 while we are not finished 2 compare the largest to the current 3 if current > largest 4 label current as largest 5 call next number in the list current 6 repeat the while 7 output the largest * 5 call next number in the list current
Programming Languages Over 200 languages Language depends upon task COBOLLogo C++ADA PascalFORTRAN BASIC
Introduction Levels of Computer Languages: Low machine assembly
Introduction Levels of Computer Languages: High COBOL Pascal FORTRAN Logo
Introduction Levels of Computer Languages: Mid-level C C++
Introduction Procedural languages Object-Oriented languages (OOP)
Computer Can’t Understand C ++ COBOLFORTRANPascalBASICADALISP
Introduction Translation to Machine Language Interpreter Compiler linker
Introduction * source code compiler - h-files used object code linked to libraries.exe file
OOP Concepts Object-Oriented Programming (OOP) Polymorphism Inheritance Encapsulation
OOP Concepts Encapsulation Self-contained unit Data Abstraction Usable without knowing how it works
OOP Concepts InheritancePolymorphism *
OOP Concepts class = a user-defined data type A class contains variables called objects and functions called methods.
“I discovered I always have choices, and sometimes it’s only a choice of attitude.” Judith M. Knowlton