Building Skills in Object-Oriented Design

Step-by-Step Construction of A Complete Application

Steven F. Lott

Creative Commons License; some rights reserved.

This work is licensed under a Creative Commons License. You are free to copy, distribute, display, and perform the work under the following conditions:

  • Attribution. You must give the original author, Steven F. Lott, credit.

  • Noncommercial. You may not use this work for commercial purposes.

  • No Derivative Works. You may not alter, transform, or build upon this work.

For any reuse or distribution, you must make clear to others the license terms of this work.

6/16/2008


Table of Contents

Preface
Why Read This Book?
Audience
Organization of This Book
Why This Subject?
Programming Style
Conventions Used in This Book
Acknowledgements
1. Foundations
Problem Statement
The Use Case
Solution Approach
Methodology, Technique and Process
On Quality
On Rework
On Decision-Making
On Reuse
On Design Patterns
Deliverables
I. Roulette
2. Roulette Details
Roulette Game
Available Bets
Some Betting Strategies
3. Roulette Solution Overview
Preliminary Survey of Classes
A Walkthrough of Roulette
Questions and Answers
4. Outcome Class
Overview
Design
Deliverables
5. Bin Class
Overview
Questions and Answers
Java Design
Python Design
Deliverables
6. Wheel Class
Overview
Design
Deliverables
7. Bin Builder Class
Overview
Algorithms
Design
Deliverables
8. Bet Class
Overview
Questions and Answers
Design
Deliverables
9. Roulette Table Class
Overview
Design
Deliverables
10. Roulette Game Class
Overview
Design
Questions and Answers
Deliverables
11. Review of Testability
Overview
Questions and Answers
Design
Deliverables
12. Player Class
Overview
Design
Deliverables
13. Overall Simulation Control
Overview
Design
Deliverables
14. Player SevenReds
Overview
Design
Deliverables
15. Statistical Measures
Overview
Some Foundations
Statistical Algorithms
Design
Deliverables
16. Player Random
Overview
Design
Deliverables
17. Player 1-3-2-6
Overview
Questions and Answers
Design
Deliverables
Advanced Exercise
18. Player Cancellation
Overview
Design
Deliverables
19. Player Fibonacci
Overview
Design
Deliverables
20. Conclusion
II. Craps
21. Craps Details
Craps Game
Available Bets
Some Betting Strategies
22. Craps Solution Overview
Preliminary Survey of Classes
A Walkthrough of Craps
Questions and Answers
23. Outcome Class
Overview
Design
Deliverables
24. Throw Class
Overview
Design
Deliverables
25. Dice Class
Overview
Design
Deliverables
26. Throw Builder Class
Overview
Questions and Answers
Design Light
Design Heavy
Deliverables
27. Bet Class
Overview
Design
Deliverables
28. CrapsTable Class
Overview
Design
Deliverables
29. CrapsGame Class
Overview
Design
Deliverables
30. CrapsPlayer Class
Overview
Design
Deliverables
31. Design Cleanup and Refactoring
Overview
Design
Deliverables
32. Simple Craps Players
Overview
Design
Deliverables
33. Roll-Counting Player
Overview
Design
Deliverables
34. Conclusion
III. Blackjack
35. Blackjack Details
Blackjack Game
Available Bets and Choices
Betting Strategies
36. Blackjack Solution Overview
Preliminary Survey of Classes
A Walkthrough
Questions and Answers
37. Card, Deck and Shoe Classes
Overview
Questions and Answers
Design
Deliverables
38. Hand and Outcome Classes
Overview
Design
Deliverables
39. Blackjack Table Class
Overview
Design
Deliverables
40. BlackjackGame Class
Overview
Design
Deliverables
41. Simple Blackjack Player Class
Overview
Design
Deliverables
42. Variant Game Rules
Overview
Design
Deliverables
43. Conclusion
A. Python unittest Testing
B. Python doctest Testing
Develop the Class
Exercise the Class
Update the Docstrings
Add the Test Framework
Mixed unittest and doctest
C. Java JUnit Testing
D. Python Epydoc Documentation
Basic Epytext Markup
Epytext Field Markup
Epydoc Example
E. Java javadoc Documentation
Basic Javadoc Markup
Javadoc Tags
Javadoc Example
Bibliography

List of Tables

17.1. 1-3-2-6 Betting States
21.1. Craps Game States
40.1. Blackjack Overall Collaboration
40.2. Blackjack Insurance Collaboration
40.3. Blackjack Fill-Hand Collaboration
41.1. Blackjack Player Strategy

List of Examples

1. Typical Python Example
1.1. Sample Java Execution
1.2. Informal Python Unit Test
1.3. Informal Java Unit Test
4.1. Object Identity
4.2. Java Simple toString Implementation
4.3. Java StringBuffer toString Implementation
4.4. Java MessageFormat toString Implementation
5.1. Java Bin Construction
5.2. Python Bin Construction
5.3. Python Appending Outcomes to A Tuple
5.4. Python String Conversion of a Tuple of Outcomes
6.1. Java Subclass Declaration
6.2. Python Subclass Declaration
7.1. Python Localization
13.1. Java Explicit Iteration Through a List of Integers
13.2. Java Compressed Iteration Through a List of Integers
14.1. Java Main Program
15.1. Java Sigma Iteration
15.2. Python Sigma Iteration
15.3. Java Sample Values by Iterator
15.4. Python Sample Values by Iterator
17.1. Java instanceof
17.2. Python player Module
17.3. Python Singleton With Class Variables
21.1. Python Frequency Distribution
21.2. Java Frequency Distribution
23.1. Java Default Method Arguments via Overloading
23.2. Python Default Method Arguments
23.3. Python Default Mutable Method Arguments
33.1. Java Creation of A Player
37.1. Python Constant Declaration
A.1. testCard.py
A.2. card.py
B.1. card.py - Initial
B.2. card.py - Revised
B.3. testCards.py
C.1. TestCard.java
C.2. Card.java
D.1. card.py
E.1. Card.py

List of Equations

15.1. Basic Summation
15.2. Summation with Half-Open Interval
15.3. Summing Elements of an Array, x
15.4. Mean
15.5. Standard Deviation