Building Skills in Object-Oriented Design, V4¶
Step-by-Step Construction of A Complete Application
This is release 4.2003, published Mar 04, 2020.
Legal Notice
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.
Getting Started¶
In this part, we’ll look at some general topics required to get started. The first chapter will provide some foundations, talking about the problem domain, the solution, and some general ideas on how the work will proceed.
The remaining chapters will provide specific guidance on setting up a working development environment, writing some basic unit tests, and starting down the road to producing useful documentation. These sections will set the stage for all of the work which follows.
Roulette¶
Roulette is a stateless game with numerous bets and a very simple process for game play.
The chapters of this part present the details on the game, an overview of the solution, and a series of sixteen exercises to build a complete simulation of the game, plus a variety of betting strategies. Each exercise chapter builds at least one class, plus unit tests; in some cases, this includes rework of previous deliverables.
- Roulette Details
- Roulette Solution Overview
- Outcome Class
- Bin Class
- Wheel Class
- Bin Builder Class
- Roulette Bet Class
- Roulette Table Class
- Roulette Game Class
- Review of Testability
- Player Class
- Overall Simulation Control
- SevenReds Player Class
- Statistical Measures
- Random Player Class
- Player 1-3-2-6 Class
- Player 1-3-2-6 Analysis
- On Polymorphism
- Player 1-3-2-6 Questions and Answers
- Player1326 State Design
- Player1326 No Wins Design
- Player1326 One Win Design
- Player1326 Two Wins Design
- Player1326 Three Wins
- Player1326 Design
- Player 1-3-2-6 Deliverables
- Advanced Exercise – Refactoring
- Advanced Exercise – Less Object Creation
- Looking Forward
- Cancellation Player Class
- Fibonacci Player Class
- Conclusion
Craps¶
This part describes parts of the more complex game of Craps. Craps is played with dice. Craps is a game with two states and a number of state-change rules. It has a variety betting alternatives, some of which are quite complex.
The chapters of this part presents the details on the game, an overview of the solution, and a series of eleven exercises to build a complete simulation of the game, with a variety of betting strategies. The exercises in this part are more advanced; unlike Roulette, we will often combine several classes into a single batch of deliverables.
There are several examples of rework in this part, some of them quite extensive. This kind of rework reflects three more advanced scenarios: refactoring to generalize and add features, renaming to rationalize the architecture, and refactoring to extract features. Each of these is the result of learning; they are design issues that can’t easily be located or explained in advance.
- Craps Details
- Craps Solution Overview
- Outcome Class
- Throw Class
- Dice Class
- Throw Builder Class
- Bet Class
- Craps Table Class
- CrapsGame Class
- Craps Game Analysis
- Design Decision – Win, Lose, Wait
- Additional Craps Design
- Craps Game Implementation Steps
- Throw Rework
- ThrowBuilder Rework
- Bet Rework
- CrapsPlayer Class Stub
- CrapsGameState Class
- CrapsGamePointOff Class
- CrapsGamePointOn Class
- CrapsGame Design
- Craps Game Deliverables
- Optional Working Bets
- Looking Forward
- CrapsPlayer Class
- Design Cleanup and Refactoring
- Simple Craps Players
- Roll-Counting Player Class
- Conclusion
Blackjack¶
This part describes the more complex game of Blackjack. This game has a number of states and a number of complex state-change rules. While the betting rules are simple, the game play is more complex.
The chapters of this part presents the details on the game, an overview of the solution, and a series of six relatively complex exercises to build a complete simulation of the game. In the case of Blackjack, we have to create a design that allows for considerable variation in the rules of the game as well as variation in the player’s betting strategies.
Fit and Finish¶
A finished application includes more than just a collection of packages. We’ll need to build a Command-Line Interface (CLI) to operate this program. This isn’t a sophisticated OO design problem. This is a collection of exercises in using the standard library to create the final application.