This lecture describe the process of designing a program through the example of a simple “desk calculator.” In this chapter you will learn: Some thoughts on software development, the idea of a calculator, using a grammar, expression evaluation, program organization. | Chapter 6 Writing a Program Bjarne Stroustrup Abstract This lecture and the next describe the process of designing a program through the example of a simple “desk calculator.” Stroustrup/Programming/2015 Overview Some thoughts on software development The idea of a calculator Using a grammar Expression evaluation Program organization Stroustrup/Programming/2015 Stroustrup/Programming/2015 A famous quote in the original Unix source code. You can’t understand everything – certainly not at first and in detail. BWK giving a memorial lecture for Dennis Ritchie, the designer of the C programming language. Building a program Analysis Refine our understanding of the problem Think of the final use of our program Design Create an overall structure for the program Implementation Write code Debug Test Go through these stages repeatedly Stroustrup/Programming/2015 Writing a program: Strategy What is the problem to be solved? Is the | Chapter 6 Writing a Program Bjarne Stroustrup Abstract This lecture and the next describe the process of designing a program through the example of a simple “desk calculator.” Stroustrup/Programming/2015 Overview Some thoughts on software development The idea of a calculator Using a grammar Expression evaluation Program organization Stroustrup/Programming/2015 Stroustrup/Programming/2015 A famous quote in the original Unix source code. You can’t understand everything – certainly not at first and in detail. BWK giving a memorial lecture for Dennis Ritchie, the designer of the C programming language. Building a program Analysis Refine our understanding of the problem Think of the final use of our program Design Create an overall structure for the program Implementation Write code Debug Test Go through these stages repeatedly Stroustrup/Programming/2015 Writing a program: Strategy What is the problem to be solved? Is the problem statement clear? Is the problem manageable, given the time, skills, and tools available? Try breaking it into manageable parts Do we know of any tools, libraries, etc. that might help? Yes, even this early: iostreams, vector, etc. Build a small, limited version solving a key part of the problem To bring out problems in our understanding, ideas, or tools Possibly change the details of the problem statement to make it manageable If that doesn’t work Throw away the first version and make another limited version Keep doing that until we find a version that we’re happy with Build a full scale solution Ideally by using part of your initial version Stroustrup/Programming/2015 Programming is also a practical still We learn by example Not by just seeing explanations of principles Not just by understanding programming language rules The more and the more varied examples the better You won’t get it right the first time “You can’t learn to ride a bike from a correspondence course”