CS208 Software ProgrammingIntroductionSlide 3LanguagesSlide 5Programming Language Capability RequirementsExample LanguagesProgram DevelopmentProgramsHigh-Level Language ProgrammingTypes of CodeSlide 12Creating Computer ProgramsStructured ProgrammingStructured Programming ConceptsStructured Programming Concepts (continued)Benefits of Structured Programming01/14/19 1CS208 Software Programming2IntroductionSoftwareInstructions that tell the computer what to do (ie. a program)Instructions are written in a programming language3Language LevelsEach type of CPU has its own specific machine languageOther language levels were created to make it easier for a human being to write programsmachine languageassembly languagehigh-level language4LanguagesMachine LanguageZeros and OnesBit representations are specific to a particular hardware architectureAssembly LanguagesUse mnemonics for operations and sometimes also for memory locationsEach assembly language is specific to a particular hardware architectureTranslated by an Assembler5LanguagesHigh Level Languages –Use English-like statements to instruct the computer what to doAre more portable (will run on different kinds of hardware)Are easier for humans to understand and program withTranslated by a Compiler6Programming Language Capability RequirementsRepresentation & Storage (of both the Data and the program Instructions)Data Processing (Interprets the program instructions and carries out the operations defined by these instructions on the Data)Data Input and Data OutputInput Data - data that is provided (is not computed) to the program as it runsOutput Data - data that the program ultimately produces (output data = solution of the computational problem)7Example LanguagesHigh Level LanguagesFORTRAN - scientific/engineering, mathCOBOL - businessBASIC - education and PCsPascal - education C/C++ - application developmentJava - application development8Program DevelopmentProgram development consists of:Discovering the underlying algorithmRepresenting that algorithm as a program using a programming language9ProgramsWhat is a program?A collection of statementsWritten in a programming languageSpecify the steps taken to solve a problemEach programming language has grammar rules that specify:How the statements are formedHow the statements are combined10High-Level Language ProgrammingProgramming requires:A programming language (e.g. C++) to express your ideasA set of tools to edit and debug your codeA compiler to translate your programs to machine code A machine to run the executable code on11Types of CodeSource code (source file)Typed into the editor by the programmer using a programming languageObject Code (object file)Translated from the source code by the compilerExecutable CodeCreated by the linker - links the object code and any necessary library object code files together12Program DevelopmentHigh-Level LanguageProgramDevelopmentComputational ProblemAn Algorithm Source code Program in a High-Level Language (e.g. C++)CompilerA machine LanguageProgram developencodeSourceCodeLinkerObjectCode13Creating Computer ProgramsAnalyze the problemPlan an algorithmHand check the algorithmCode the algorithm (or write program)Hand check (trace through) the programEvaluate and modify program as necessary14Structured ProgrammingStructured Programming is a technique used to create well-formed programsUses top-down design with stepwise refinementLarger pieces of code are broken into shorter pieces of code that encompass a single taskTask are repeatedly broken down into smaller tasks, until they are small enough to be understood easily15Structured Programming ConceptsFinal program is created via top-down design. Main code starts with empty modules, and is slowly refined to lowest level Program is subdivided into modules (one logical task, generally no more than one page long)Keeps programmer from being overwhelmed by the size of the jobAllows easy division of work (modules assigned to different programmers)16Structured Programming Concepts (continued) Each module is organized into recognizable paragraphs, using indentation to show nesting and subordinate clauses.Code structures should have only one entry point and one point of exit (no GOTO).Embedded comments describe the function of each data item and purpose of each module.Straightforward, easily readable code is preferred over slightly more efficient, but obtuse, code.17Benefits of Structured ProgrammingMore readableEasier to maintainMore flexibleMore likely to be correct on first runEasier to "prove" by systematic program
View Full Document