Skip to main content Accessibility help
×
Hostname: page-component-77c89778f8-7drxs Total loading time: 0 Render date: 2024-07-22T14:33:20.832Z Has data issue: false hasContentIssue false

Chapter 6 - Procedural programming basics

Published online by Cambridge University Press:  05 June 2012

David Yevick
Affiliation:
University of Waterloo, Ontario
Get access

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 Engineering
C++, Java and Octave Numerical Programming with Free Software Tools
, pp. 35 - 57
Publisher: Cambridge University Press
Print publication year: 2012

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Procedural programming basics
  • David Yevick, University of Waterloo, Ontario
  • Book: A Short Course in Computational Science and Engineering
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9781139022262.006
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Procedural programming basics
  • David Yevick, University of Waterloo, Ontario
  • Book: A Short Course in Computational Science and Engineering
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9781139022262.006
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Procedural programming basics
  • David Yevick, University of Waterloo, Ontario
  • Book: A Short Course in Computational Science and Engineering
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9781139022262.006
Available formats
×