Books / Patterns for Beginning Programmers / Chapter 1
Part I - Patterns Requiring Knowledge of Types, Variables, and Arithmetic Operators
Part I contains programming patterns that require an understanding of data types, variables and identifiers, the declaration of variables and a basic understanding of memory, the assignment operator and its impact on memory, and arithmetic operators. Many of the patterns in this part of the book make extensive use of integer arithmetic.
Specifically, this part of the book contains the following programming patterns:
Updating. Solutions to the problem of how to update a variable.
Swapping. A solution to the problem of swapping the contents of two variables (of the same type).
Digit Manipulation. Solutions to the problems of extracting and deleting the digits of an integer (from both the right and left sides).
Arithmetic on the Circle. A solution to the problem of performing basic arithmetic operations on quantities that repeat themselves (e.g., days of the week, months of the year).
Truncation. Solutions to the problem of truncating an integer to a particular digit (i.e., power of 10).
The patterns in this part of the book arise so frequently that they are second nature to experienced programmers, which can be quite annoying for beginning programmers, who have to think about them every time they make use of them. In and of itself, this observation is evidence for the importance of studying both these patterns and those in the other parts of this book.