The essence of many computer applications is numerical computation, a topic
that is:
Experience shows that using objects to represent numerical quantities ensures type safety and units integrity, and also facilitates future change. Compared with Fortran-like use of built-in floating-point types, the resulting programs are much easier to understand, relatively bug-free, and far more economical to maintain. |
This course examines certain common patterns and shows the participants how they can quickly
design and build robust numeric object-oriented classes and the application programs that use them.
Each participant receives:
|
Length:2 half-day sessions. Prerequisites:
| What about Java?Although Java is hardly the language of choice for heavy-duty computation, a programmer who has mastered the concepts and techniques of this short course can apply them effectively for moderate computation in Java. After you take this course, see Java for Computation, a single-session presentation. |
We begin with a quick review of C++'s facilities for defining numeric object classes.
We first examine in depth a pure numeric (i.e. without unit of measure) data type,
such as Complex numbers (for engineering/scientific programmers) or
Rational numbers (fractions), noting its structure and techniques.
We then go on to look at our first class having an additive unit of measure, such as
At the close of the first half-day session1 we assign a homework exercise that gives the participants a chance to design and develop a complete and robust additive numeric class. |
Building on the notions of units integrity and type safety, we begin the second session by examining
pairs of numeric data types that follow the Point-Extent Pattern, emphasizing
how we avoid common pitfalls, drawing examples from engineering or business problems depending on the
participants' backgrounds and interests.
Finally, we generalize the techniques we've been using to accommodate arbitrarily large families of related interacting data types. If time permits, we explore briefly ways of capturing and reusing the various patterns that have emerged in our study of numeric data types. We conclude with another assigned exercise2, that gives the participants a chance to integrate the knowledge they've gained from this course and to develop a useful real-world family of interacting classes. |
1 -- We strongly recommend scheduling the two half-day sessions at least two days apart, to give the participants a chance to reinforce their understanding of the concepts and techniques, to do a hands-on exercise, and to catch up if they've fallen behind. Alternatively, if geographic or scheduling constraints demand, we're willing to conduct PR-13C as a full-day course with morning and afternoon sessions and no homework exercise.
2An optional follow-up session can be arranged to discuss solutions to the assignment.
Return to course list
C++ curriculum
IDI home page
Last modified 10 November, 2001