Operating System CSCI 125 & 161 / ENGR 144 • Program that acts as interface to other Lecture 3 software and the underlying hardware Operating System Utilities Compilers Martin van Bommel Utility Programs Assemblers Editors Hardware E-mail 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 Programming Errors • Integrated Development Environment • Vocabulary and grammar - syntax – combines editor, compiler, linker, loader • Rules determine if statement legally – usually includes tools to assist in debugging constructed - syntax rules • Note • Compiler checks rules - gives syntax errors – IDE’s do not always write to disk automatically • Programs also contain errors in logic - bugs – must remember to save work to disk often, especially before executing a program • Debugging - finding & fixing logic errors • e.g. 1962 Mariner I Venus probe crashed due to missing hyphen (-) 1
Initial Program Program Development #include <iostream> - library inclusion • Software Engineering • study and use of techniques for - symbol namespace using namespace std; programming and problem solving void main() - function “main” { • Software Life Cycle cout << ”Hello world!”; - call function “cout” • software development goes through cycles, } to display string where begins again when software outdated Software Life Cycle Problem Analysis and Spec. 1. Specify the problem requirements. • Determine its input 2. Analyze the problem. – what information is given – what items are important to solving problem 3. Design the algorithm to solve the problem. • Determine its output 4. Implement the program. – what information must be produced to solve the 5. Test and verify the completed program. problem 6. Maintain and update the program. • Determine scope of the problem – questions, questions, and more questions Algorithm Design Algorithm • Procedure to convert inputs to outputs • Three basic forms of control • Uses step-by-step process 1. Sequential - one step after another • Top-down step-wise refinement 2. Selection - choose one of many alternatives • Produce pseudo-code or flowchart 3. Repetition - one or more steps repeatedly 2
START Program Coding GET NUMBER ADD NUMBER • Program should be correct, readable, and understandable 10 • Simple and clear - no tricks NUMBERS? NO • Modular - program and test subtasks of YES overall problem separately DIVIDE BY 10 • Conforms to syntax of language PRINT RESULT END Program Formatting Execution and Testing • Spaces between items in statements • Test each unit separately before combining – between variables and operators • Use expected data with known result • Blank lines between major sections • Use unexpected data to check for problems – each subpart separated from others • Good indentation • Validation - tested with several sets of test – indent statements in loops data, but never can tell if absolutely valid. • Meaningful variable names – Distance and Time instead of d and t Program Maintenance • Programs survive for many years • New features must be added • Laws, rules, and procedures change • Hardware changes • e.g. Year 2000 problem 3
Recommend
More recommend