CSCI 125 161 ENGR 144 Lecture 3 Martin

  • Slides: 17
Download presentation
CSCI 125 & 161 / ENGR 144 Lecture 3 Martin van Bommel

CSCI 125 & 161 / ENGR 144 Lecture 3 Martin van Bommel

Operating System • Program that acts as interface to other software and the underlying

Operating System • Program that acts as interface to other software and the underlying hardware Operating System Utility Programs Hardware Utilities Compilers Assemblers Editors E-mail

HLL to Machine Language • Enter HLL program into file using editor – program.

HLL to Machine Language • Enter HLL program into file using editor – program. cpp - source file • Translate source code to machine code - compiler – program. obj - object file • Combine object code with libraries - linker – program. exe - executable file • Move program to memory - loader

IDE • Integrated Development Environment – combines editor, compiler, linker, loader – usually includes

IDE • Integrated Development Environment – combines editor, compiler, linker, loader – usually includes tools to assist in debugging • Note – IDE’s do not always write to disk automatically – must remember to save work to disk often, especially before executing a program

Programming Errors • Vocabulary and grammar - syntax • Rules determine if statement legally

Programming Errors • Vocabulary and grammar - syntax • Rules determine if statement legally constructed - syntax rules • Compiler checks rules - gives syntax errors • Programs also contain errors in logic - bugs • Debugging - finding & fixing logic errors • e. g. 1962 Mariner I Venus probe crashed due to missing hyphen (-)

Initial Program #include <iostream> - library inclusion using namespace std; - symbol namespace int

Initial Program #include <iostream> - library inclusion using namespace std; - symbol namespace int main() { cout << ”Hello world!”; return 0; } - function “main” - call function “cout” to display string - expected value to OS

Program Development • Software Engineering • study and use of techniques for programming and

Program Development • Software Engineering • study and use of techniques for programming and problem solving • Software Life Cycle • software development goes through cycles, where begins again when software outdated

Software Life Cycle 1. 2. 3. 4. 5. 6. Specify the problem requirements. Analyze

Software Life Cycle 1. 2. 3. 4. 5. 6. Specify the problem requirements. Analyze the problem. Design the algorithm to solve the problem. Implement the program. Test and verify the completed program. Maintain and update the program.

Problem Analysis and Spec. • Determine its input – what information is given –

Problem Analysis and Spec. • Determine its input – what information is given – what items are important to solving problem • Determine its output – what information must be produced to solve the problem • Determine scope of the problem – questions, and more questions

Algorithm Design • Procedure to convert inputs to outputs • Uses step-by-step process •

Algorithm Design • Procedure to convert inputs to outputs • Uses step-by-step process • Top-down step-wise refinement • Produce pseudo-code or flowchart

Algorithm • Three basic forms of control 1. Sequential - one step after another

Algorithm • Three basic forms of control 1. Sequential - one step after another 2. Selection - choose one of many alternatives 3. Repetition - one or more steps repeatedly

START GET NUMBER ADD NUMBER NO 10 NUMBERS? YES DIVIDE BY 10 PRINT RESULT

START GET NUMBER ADD NUMBER NO 10 NUMBERS? YES DIVIDE BY 10 PRINT RESULT END

Program Coding • Program should be correct, readable, and understandable • Simple and clear

Program Coding • Program should be correct, readable, and understandable • Simple and clear - no tricks • Modular - program and test subtasks of overall problem separately • Conforms to syntax of language

Program Formatting • Spaces between items in statements – between variables and operators •

Program Formatting • Spaces between items in statements – between variables and operators • Blank lines between major sections – each subpart separated from others • Good indentation – indent statements in loops • Meaningful variable names – Distance and Time instead of d and t

Execution and Testing • Test each unit separately before combining • Use expected data

Execution and Testing • Test each unit separately before combining • Use expected data with known result • Use unexpected data to check for problems • Validation - tested with several sets of test data, but never can tell if absolutely valid.

Program Maintenance • • Programs survive for many years New features must be added

Program Maintenance • • Programs survive for many years New features must be added Laws, rules, and procedures change Hardware changes • e. g. Year 2000 problem