6.

Chapter 4: Debugging and the Testing Process

Listing 2-1: DrJava's GlobalModel Provides an Interface that Maintains Limited Connections between the View and the Model

Chapter 7: The Rogue Tile

Listing 7-1: A Common Binary Tree Class Hierarchy
Listing 7-2: Factoring Out Common Code from Listing 7-1.
Listing 7-3: Using a Design Pattern to Factor Out Common Code (Correctly)
Listing 7-4: Modifying Class Code After Common Code Is Factored Out
Listing 7-5: Adding Visitors to the Tree Hierarchy
Listing 7-6: A Parametric Version of Interface TreeVisitor

Chapter 9: The Dangling Composite

Listing 9-1: A Dangling Composite in a Singly Linked Implementation of Lists
Listing 9-2: Defining getter and setter Methods for LinkedList
Listing 9-3: Writing an equals() Method for the Linked Lists
Listing 9-4: Fixing the equals() Method with a Preemptive Test
Listing 9-5: A Fix That Rewrites the Single-Argument Constructor
Listing 9-6: The LinkedList Class Acts as a Container for an Immutable List
Listing 9-7: Implementing the Immutable Lists

Chapter 10: The Null Flag

Listing 10-1: A Simple Bridge Class
Listing 10-2: Rewriting to Throw the Proper, Expected Exception

Chapter 11: The Double Descent

Listing 11-1: A Class Hierarchy for Binary Trees of ints That Allows for Empty Trees
Listing 11-2: Adding Methods to Ferret Out 0 Values in Adjacent Nodes
Listing 11-3: Casting to Branches To Fix Inability to Compile
Listing 11-4: Wrapping Each Cast in an instanceof Check
Listing 11-5: Using Extra Methods to Avoid Rewriting instanceof Checks

Chapter 12: The Liar View

Listing 12-1: The Pause Lets Us Place the Test in Slow-Motion Mode
Listing 12-2: Rewriting to Check View Properties After Model State Changes

Chapter 13: Saboteur Data

Listing 13-1: Data from an Outside Source Text File
Listing 13-2: Defining PreparedStatement Object for Passing Data

Chapter 14: The Broken Dispatch

Listing 14-1: Implementing the Immutable Lists
Listing 14-2: Defining Enforcement Parameters for Linked Lists
Listing 14-3: New Constructor Takes Only String Representation of List as Argument
Listing 14-4: Upcasting the Arguments in the Method Invocation

Chapter 15: The Impostor Type

Listing 15-1: Implementation of Shapes with Impostor Types
Listing 15-2: Constructing a New Form
Listing 15-3: Implementation of Forms with Real Types
Listing 15-4: A Cross-Breed Implementation

Chapter 16: The Split Cleaner

Listing 16-1: Code That Walks over a Table of Employees
Listing 16-2: Code Walker to Update Old Data
Listing 16-3: Code Refactored So That Resources Are Obtained and Released in the Same Method

Chapter 17: The Fictitious Implementation

Listing 17-1: An Interface for Stacks
Listing 17-3: An Assertion to Test a Stack's Interface
Listing 17-4: Unit Tests for Stacks

Chapter 18: The Orphaned Thread

Listing 18-1: A Simple, Multithreaded Consumer-Producer Program.
Listing 18-2: Example in Which the Client Thread Is Notified of an Error

Chapter 19: The Run-On Initialization

Listing 19-1: A Simple Run-On Initialization
Listing 19-2: RestrictedInts with NonValues
Listing 19-3: NonValues That Throw Exceptions
Listing 19-4: Lists with No Universal getters
Listing 19-5: Lists with getters in the Interface

Chapter 20: Platform-Dependent Patterns

Listing 20-1: A Tail-Recursive Factorial
Listing 20-2: A Purely Recursive Factorial

Appendix A: String-Parsing List Constructor

Listing A-1: String-Parsing List Constructor



Bug Patterns in Java
Bug Patterns In Java
ISBN: 1590590619
EAN: 2147483647
Year: N/A
Pages: 95
Authors: Eric Allen

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net