Part II - Patterns Requiring Knowledge of Logical and Relational Operators, Conditions, and Methods

Part II contains programming patterns that require an understanding of logical operators, relational operators, conditions, and methods. Specifically, this part of the book contains the following programming patterns:

Indicators. Solutions to problems in which a binary variable is used to determine whether or not another variable should be increased/decreased by an amount/percentage.

Indicator Methods. Solutions to problems in which an indicator must be calculated before it can be used.

Rounding. Solutions to the problem of rounding (rather than truncating) an integer to a particular digit (i.e., power of 10).

Starts and Completions. Solutions to problems that require the number of tasks started and/or completed given a measure of work and an amount of work per task.

Bit Flags. Solutions to problems in which the flow of a program needs to be controlled based on the state of one or more binary values.

Digit Counting. A solution to the problem of determining the number of digits in an integer.

Some of the patterns in this part of the book don’t make direct use of the prerequisite concepts but alternative solutions do. This is true, for example, of indicators. Some of the patterns in this part of the book make direct use of only some of of the prerequisite concepts (e.g., bit flags make use of relational operators and digit counting makes use of methods). Other patterns in this part of the books make direct use of all of the prerequisite concepts (e.g., indicator methods, rounding, and starts and completions). Hence, you may be able to understand some of these patterns before you have learned about all of the prerequisite concepts.

It’s also important to note that many of the patterns in this part of the book make use of patterns from earlier in the book. Hence, it is important to understand the patterns from Part I before starting on Part II.

Finally, some of the patterns in this part of the book can be thought of as specific examples of a more abstract pattern. However, that view requires a level of sophistication that beginning programmers may not have, so they are not presented in that way.