Sprint 2 Guides¶
These guides support Sprint 2. Read them as you work through the requirements.
Design Patterns¶
| Guide | When to Read |
|---|---|
| Introduction to Design Patterns | Before starting — understand what design patterns are and why they matter |
| The Observer Pattern | Requirements 3, 6, 7 — PropertyChangeListener, PropertyChangeSupport, and event-driven updates |
| Model-View-Controller (MVC) | Requirements 2–7 — understand the architecture you're building: Model (TetrisGame), View (panels), Controller (key/menu handlers) |
| The Strategy Pattern | Supplementary — understand the Map-based strategy pattern used in the back-end API |
GUI & Events¶
| Guide | When to Read |
|---|---|
| Handling Key Events | Requirement 5 — KeyListener, KeyAdapter, and three patterns for mapping keys to actions |
| Animation with javax.swing.Timer | Requirement 2 — setting up the game timer, start/stop, and why Timer runs on the EDT |
| Adding Event Handlers | Review — ActionListener patterns for menu items and timer callbacks |
References¶
Primary Texts:
- Gamma, E., Helm, R., Johnson, R., & Vlissides, J. (1994). Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley. — Observer pattern (pp. 293–303), Strategy pattern (pp. 315–323), MVC introduction (pp. 4–6).
- Freeman, E., & Robson, E. (2020). Head First Design Patterns (2nd ed.). O'Reilly. — Chapter 2: Observer Pattern, Chapter 12: MVC compound pattern.
- Horstmann, C. S. (2022). Core Java, Volume I: Fundamentals (12th ed.). Oracle Press. — Swing event handling, Timer, PropertyChangeListener.
- Bloch, J. (2018). Effective Java (3rd ed.). Addison-Wesley. — Item 42: Prefer lambdas to anonymous classes; Item 43: Prefer method references to lambdas.
Language Documentation:
- Oracle JDK 25: PropertyChangeListener — Observer interface for property changes
- Oracle JDK 25: PropertyChangeSupport — Helper class for managing observers
- Oracle JDK 25: javax.swing.Timer — EDT-safe timer for periodic events
- Oracle JDK 25: KeyListener — Keyboard event interface
- Oracle JDK 25: KeyAdapter — Convenience adapter for KeyListener
Tutorials:
- Oracle: How to Write a Key Listener — Official Swing key event tutorial
- Oracle: How to Use Swing Timers — Official Swing Timer tutorial
- Tetris Back-End API Documentation — Game model Javadoc