Book contents
- Frontmatter
- Contents
- Chapter 1 Introduction
- Chapter 2 Octave programming
- Chapter 3 Installing and running the Dev-C++ programming environment
- Chapter 4 Introduction to computer and software architecture
- Chapter 5 Fundamental concepts
- Chapter 6 Procedural programming basics
- Chapter 7 An introduction to object-oriented analysis
- Chapter 8 C++ object-oriented programming syntax
- Chapter 9 Arrays and matrices
- Chapter 10 Input and output streams
- Chapter 11 References
- Chapter 12 Pointers and dynamic memory allocation
- Chapter 13 Memory management
- Chapter 14 The static keyword, multiple and virtual inheritance, templates and the STL
- Chapter 15 Creating a Java development environment
- Chapter 16 Basic Java programming constructs
- Chapter 17 Java classes and objects
- Chapter 18 Advanced Java features
- Chapter 19 Introductory numerical analysis
- Chapter 20 Linear algebra
- Chapter 21 Fourier transforms
- Chapter 22 Differential equations
- Chapter 23 Monte Carlo methods
- Chapter 24 Partial differential equations
- Index
Chapter 6 - Procedural programming basics
Published online by Cambridge University Press: 05 June 2012
- Frontmatter
- Contents
- Chapter 1 Introduction
- Chapter 2 Octave programming
- Chapter 3 Installing and running the Dev-C++ programming environment
- Chapter 4 Introduction to computer and software architecture
- Chapter 5 Fundamental concepts
- Chapter 6 Procedural programming basics
- Chapter 7 An introduction to object-oriented analysis
- Chapter 8 C++ object-oriented programming syntax
- Chapter 9 Arrays and matrices
- Chapter 10 Input and output streams
- Chapter 11 References
- Chapter 12 Pointers and dynamic memory allocation
- Chapter 13 Memory management
- Chapter 14 The static keyword, multiple and virtual inheritance, templates and the STL
- Chapter 15 Creating a Java development environment
- Chapter 16 Basic Java programming constructs
- Chapter 17 Java classes and objects
- Chapter 18 Advanced Java features
- Chapter 19 Introductory numerical analysis
- Chapter 20 Linear algebra
- Chapter 21 Fourier transforms
- Chapter 22 Differential equations
- Chapter 23 Monte Carlo methods
- Chapter 24 Partial differential equations
- Index
Summary
The following three chapters introduce basic C++ program structure and syntax in the context first of procedural programming and subsequently, in the two later chapters, of object-oriented programming. The material in these chapters addresses the significant challenges encountered by beginning programmers.
Scientific software development
Procedural programing follows a clearly defined set of steps, which are discussed individually in this section.
Problem definition. First, a problem description that captures the main scenarios (possible outcomes), including possible abnormal situations, such as, for example, those generated by erroneous input data, should be formulated.
Detailed specification. A program specification comprises a detailed solution strategy such as the form and content of the input and output data, the equations to be programmed, the numerical methods to be employed, the hardware and software to be used and the manner in which the code will handle the various scenarios. This can be facilitated by first generating the input and output screens that the user will encounter.
Iterative coding and modular testing. Subsequently, the program tasks should be compartmentalized into functions. Each of these should be verified independently with a set of test data that is subsequently saved in comment lines for possible future use. Comments should be supplied for each additional function or block of code and the verified code modules packaged for reuse in other projects. As a rule, only a single change or function is added to the program at a time before retesting. In addition, before implementing any non-trivial change, the previous version of the code (with an appropriate version number) should be saved in case an inadvertent error is introduced. An editor that can identify the differences between two text files can then find subtle errors such as adding an additional (sometimes invisible) character during editing.
- Type
- Chapter
- Information
- A Short Course in Computational Science and EngineeringC++, Java and Octave Numerical Programming with Free Software Tools, pp. 35 - 57Publisher: Cambridge University PressPrint publication year: 2012