did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

We're the #1 textbook rental company. Let us show you why.

9780131482395

Agile Java¿ Crafting Code with Test-Driven Development

by
  • ISBN13:

    9780131482395

  • ISBN10:

    0131482394

  • Edition: 1st
  • Format: Paperback
  • Copyright: 2005-02-14
  • Publisher: Prentice Hall

Note: Supplemental materials are not guaranteed with Rental or Used book purchases.

Purchase Benefits

  • Free Shipping Icon Free Shipping On Orders Over $35!
    Your order must be $35 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • eCampus.com Logo Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $59.99 Save up to $15.00
  • Rent Book $47.99
    Add to Cart Free Shipping Icon Free Shipping

    TERM
    PRICE
    DUE
    USUALLY SHIPS IN 2-3 BUSINESS DAYS
    *This item is part of an exclusive publisher rental program and requires an additional convenience fee. This fee will be reflected in the shopping cart.

Supplemental Materials

What is included with this book?

Summary

Master Java 5.0 and TDD Together: Build More Robust, Professional SoftwareMaster Java 5.0, object-oriented design, and Test-Driven Development (TDD) by learning them together. Agile Java weaves all three into a single coherent approach to building professional, robust software systems. Jeff Langr shows exactly how Java and TDD integrate throughout the entire development lifecycle, helping you leverage today's fastest, most efficient development techniques from the very outset. Langr writes for every programmer, even those with little or no experience with Java, object-oriented development, or agile methods. He shows how to translate oral requirements into practical tests, and then how to use those tests to create reliable, high-performance Java code that solves real problems. Agile Java doesn't just teach the core features of the Java language: it presents coded test examples for each of them. This TDD-centered approach doesn't just lead to better code: it provides powerful feedback that will help you learn Java far more rapidly. The use of TDD as a learning mechanism is a landmark departure from conventional teaching techniques. bull; bull; Presents an expert overview of TDD and agile programming techniques from the Java developer's perspective bull; Brings together practical best practices for Java, TDD, and OO design bull; Walks through setting up Java 5.0 and writing your first program bull; Covers all the basics, including strings, packages, and more bull; Simplifies object-oriented concepts, including classes, interfaces, polymorphism, and inheritance bull; Contains detailed chapters on exceptions and logging, math, I/O, reflection, multithreading, and Swing bull; Offers seamlessly-integrated explanations of Java 5.0's key innovations, from generics to annotations bull; Shows how TDD impacts system design, and vice versa bull; Complements any agile or traditional methodology, including Extreme Programming (XP) copy; Copyright Pearson Education. All rights reserved.

Author Biography

Jeff Langr has more than twenty years of development experience. He currently consults on software development, design, and agile processes through his company, Langr Software Solutions (www.LangrSoft.com). Langr worked for Uncle Bob Martin for two years at Object Mentor. He is the author of Essential Java Style (Prentice Hall PTR, 1999), and has published widely on Java and TDD in Software Development, C/C++ Users Journal, and diverse online magazine sites and portals.

www.langrsoft.com


© Copyright Pearson Education. All rights reserved.

Table of Contents

About the Author xix
Foreword xxi
Acknowledgments xxiii
Introduction 1(2)
Who Is This Book For?
3(1)
What This Book Is Not
4(1)
How to Use This Book
5(1)
Exercises
6(1)
Conventions Used in This Book
6(3)
An Agile Overview
9(12)
What Is ``Agile?''
9(2)
What Is Java?
11(2)
Why OO?
13(1)
What Is an Object?
13(1)
What Are Classes?
14(2)
Why UML?
16(1)
What Is Inheritance?
17(1)
Why Test-Driven Development?
18(3)
Setting Up
21(544)
Software You'll Need
21(5)
Does It Work?
26(1)
Compiling Hello World
27(1)
Executing Hello World
27(1)
Still Stuck?
28(3)
Getting Started
31(32)
Testing
31(1)
Design
32(1)
A Simple Test
33(2)
JUnit
35(2)
Adding a Test
37(2)
Creating a Student
39(1)
Creating the Student Class
40(1)
Constructors
41(1)
Local Variables
42(2)
Returning a Value from a Method
44(2)
Assertions
46(3)
Instance Variables
49(3)
Summarizing the Test
52(1)
Refactoring
53(2)
this
55(2)
private
57(2)
Naming Conventions
59(2)
Whitespace
61(1)
Exercises
62(1)
Java Basics
63(40)
CourseSession
63(2)
Enrolling Students
65(1)
int
65(3)
Initialization
68(1)
Default Constructors
69(1)
Suites
70(1)
The SDK and java.util.ArrayList
71(2)
Adding Objects
73(2)
Incremental Refactoring
75(1)
Objects in Memory
76(2)
Packages and the import Statement
78(1)
The java.lang Package
79(1)
The Default Package and the package Statement
79(2)
The setup Method
81(2)
More Refactoring
83(1)
Class Constants
84(2)
Dates
86(1)
Overload Constructors
86(5)
Deprecation Warnings
91(1)
Refactoring
92(3)
Creating Dates with Calendar
95(1)
Comments
96(1)
Javadoc Comments
97(3)
Exercises
100(3)
Strings and Packages
103(30)
Characters and Strings
103(3)
Strings
106(1)
StringBuilder
107(2)
System Properties
109(1)
Looping Through All Students
110(2)
Single-Responsibility Principle
112(3)
Refactoring
115(3)
System.out
118(1)
Using System.out
119(1)
Refactoring
120(1)
Package Structure
121(1)
Access Modifiers
122(6)
Using Ant
128(3)
Exercises
131(2)
Class Methods and Fields
133(30)
Class Methods
133(4)
Class Variables
137(1)
Operating on Class Variables with Class Methods
138(3)
Static Import
141(3)
Incrementing
144(1)
Factory Methods
145(2)
Simple Design
147(1)
Static Dangers
147(1)
Using Statics: Various Notes
148(1)
Jeff's Rule of Statics
149(1)
Booleans
150(4)
Tests as Documentation
154(3)
More on Initialization
157(1)
Exceptions
158(1)
Revisiting Primitive-Type Field Initialization
159(1)
Exercises
160(3)
Interfaces and Polymorphism
163(32)
Sorting: Preparation
163(1)
Sorting: Collections.sort
164(1)
CourseReportTest
165(1)
Interfaces
166(2)
Why Interfaces
168(1)
Implementing Comparable
169(2)
Sorting on Department and Number
171(1)
The if Statement
172(1)
Grading Students
173(1)
Floating-Point Numbers
173(2)
Testing Grades
175(3)
Refactoring
178(1)
Enums
179(2)
Polymorphism
181(6)
Using Interface References
187(2)
ArrayList and the List Interface
189(1)
Exercises
189(6)
Inheritance
195(36)
The switch Statement
195(1)
Case Labels Are Just Labels
196(3)
Maps
199(2)
Inheritance
201(3)
Abstract Classes
204(2)
Extending Methods
206(1)
Refactoring
207(2)
Enhancing the Grade Enum
209(1)
Summer Course Sessions
210(1)
Calling Superclass Constructors
211(4)
Refactoring
215(3)
More on Constructors
218(2)
Inheritance and Polymorphism
220(1)
The Principle of Subcontracting
220(8)
Exercises
228(3)
Legacy Elements
231(38)
Looping Constructs
232(1)
Breaking Up a Student's Name
232(2)
The while Loop
234(6)
Comparing Java Loops
240(1)
Refactoring
241(1)
Looping Control Statements
242(3)
The Ternary Operator
245(1)
Legacy Collections
246(1)
Iterators
247(2)
Iterators and the for-each Loop
249(1)
Casting
250(2)
Wrapper Classes
252(3)
Arrays
255(9)
Refactoring
264(2)
Exercises
266(3)
Exceptions and Logging
269(42)
Exceptions
270(2)
Dealing With Exceptions
272(1)
Checked Exceptions
273(2)
Exception Hierarchy
275(1)
Creating Your Own Exception Type
276(2)
Checked Exceptions vs. Unchecked Exceptions
278(1)
Messages
279(1)
Catching Multiple Exceptions
280(2)
Rethrowing Exceptions
282(3)
Stack Traces
285(1)
The finally Block
285(2)
Refactoring
287(3)
Logging
290(1)
Logging in Java
291(3)
Testing Logging
294(4)
Logging to Files
298(2)
Testing Philosophy for Logging
300(2)
More on FileHandler
302(1)
Logging Levels
302(2)
Logging Hierarchies
304(1)
Additional Notes on Logging
305(1)
Exercises
305(6)
Maps and Equality
311(38)
Logical Operators
311(2)
Short-Circuiting
313(1)
Hash Tables
313(2)
Courses
315(2)
Refactoring Session
317(6)
Equality
323(3)
The Contract for Equality
326(1)
Apples and Oranges
327(2)
Collections and Equality
329(1)
Hash Tables
330(2)
Collisions
332(1)
An Ideal Hash Algorithm
333(2)
A Final Note on hashCode
335(2)
More on Using HashMaps
337(4)
Additional Hash Tables and Set Implementations
341(2)
toString
343(2)
Strings and Equality
345(1)
Exercises
346(3)
Mathematics
349(30)
BigDecimal
350(3)
More on Primitive Numerics
353(1)
Integer Math
354(1)
Numeric Casting
355(1)
Expression Evaluation Order
356(1)
NaN
357(1)
Infinity
358(1)
Numeric Overflow
359(1)
Bit Manipulation
360(8)
Java.lang.Math
368(2)
Numeric Wrapper Classes
370(1)
Random Numbers
371(4)
Exercises
375(4)
IO
379(46)
Organization
379(1)
Character Streams
380(5)
Writing to a File
385(3)
Java.io.File
388(1)
Byte Streams and Conversion
389(1)
A Student User Interface
390(3)
Testing the Application
393(2)
Data Streams
395(1)
CourseCatalog
396(3)
Advanced Streams
399(1)
Object Streams
399(8)
Random Access Files
407(1)
The Student Directory
408(2)
sis.db.DataFileTest
410(2)
Static Nested Classes and Inner Classes
412(1)
sis.db.DataFile
413(3)
sis.db.KeyFileTest
416(2)
sis.db.KeyFile
418(1)
sis.util.IOUtilTest
419(1)
sis.util.IOUtil
420(1)
sis.util.TestUtil
421(1)
Developing the Solution
422(1)
Exercises
422(3)
Reflection and Other Advanced Topics
425(36)
Mock Objects Revisited
425(2)
The Jim Bob ACH Interface
427(2)
The Mock Class
429(2)
The Account Class Implementation
431(2)
Anonymous Inner Classes
433(2)
Adapters
435(2)
Accessing Variables from the Enclosing Class
437(2)
Tradeoffs
439(1)
Reflection
440(1)
Using JUnit Code
441(1)
The Class Class
442(2)
Building the Suite
444(2)
Class Modifiers
446(2)
Dynamic Proxy
448(1)
A Secure Account Class
449(2)
Building the Secure Account Solution
451(5)
The SecureProxy Class
456(3)
Problems With Reflection
459(1)
Exercises
459(2)
Mulithreading
461(48)
Multithreading
462(1)
Search Server
462(1)
The Search Class
463(3)
Less Dependent Testing
466(4)
The Server
470(2)
Waiting in the Test
472(1)
Creating and Running Threads
473(4)
Cooperative and Preemptive Multitasking
477(1)
Synchronization
478(2)
Creating Threads with Runnable
480(1)
Synchronized
481(1)
Synchronized Collections
482(1)
BlockingQueue
483(2)
Stopping Threads
485(1)
Wait/Notify
486(5)
Additional Notes on wait and notify
491(1)
Locks and Conditions
492(2)
Thread Priorities
494(1)
Deadlocks
495(1)
ThreadLocal
495(4)
The Timer Class
499(2)
Thread Miscellany
501(5)
Summary: Basic Design Principles for Synchronization
506(1)
Exercises
506(3)
Generics
509(26)
Parameterized Types
509(1)
Collection Framework
510(1)
Multiple Type Parameters
511(1)
Creating Parameterized Types
511(3)
Erasure
514(2)
Upper Bounds
516(2)
Wildcards
518(2)
Implications of Using Wildcards
520(2)
Generic Methods
522(1)
Wildcard Capture
522(1)
Super
523(2)
Additional Bounds
525(1)
Raw Types
526(2)
Checked Collections
528(2)
Arrays
530(1)
Additional Limitations
531(1)
Reflection
532(1)
Final Notes
532(1)
Exercises
533(2)
Assertions and Annotations
535(30)
Assertions
535(2)
The assert Statement vs. JUnit Assert Methods
537(1)
Annotations
537(1)
Building a Testing Tool
538(1)
TestRunnerTest
539(1)
TestRunner
540(3)
The @TestMethod Annotation
543(2)
Retention
545(1)
Annotation Targets
546(2)
Skipping Test Methods
548(1)
Modifying TestRunner
548(2)
Single-Value Annotations
550(2)
A TestRunner User Interface Class
552(1)
Array Parameters
553(2)
Multiple Parameter Annotations
555(2)
Default Values
557(1)
Additional Return Types and Complex Annotation Types
558(1)
Package Annotations
559(2)
Compatibility Considerations
561(1)
Additional Notes on Annotations
561(1)
Summary
562(1)
Exercises
562(3)
Additional Lesson I: Swing, Part 1
565(42)
Swing
566(1)
Getting Started
567(4)
Swing Application Design
571(1)
Panels
572(4)
Refactoring
576(4)
More Widgets
580(3)
Refactoring
583(3)
Button Clicks and ActionListeners
586(2)
List Models
588(3)
The Application
591(3)
Layout
594(8)
GridBagLayout
602(4)
Moving Forward
606(1)
Additional Lesson II: Swing, Part 2
607(46)
Miscellaneous Aesthetics
608(4)
Feel
612(23)
Tables
635(5)
Feedback
640(7)
Responsiveness
647(3)
Remaining Tasks
650(1)
Final Notes
651(2)
Additional Lesson III: Java Miscellany
653(48)
JARs
653(3)
Regular Expressions
656(6)
Cloning and Covariance
662(2)
JDBC
664(9)
Internationalization
673(8)
Call by Reference versus Call by Value
681(2)
Java Periphery
683(10)
What Else Is There?
693(8)
Appendix A: An Agile Java Glossary
701(14)
Appendix B: Java Operator Precedence Rules
715(2)
Appendix C: Getting Started with IDEA
717(16)
IDEA
717(1)
The Hello Project
718(6)
Running Tests
724(5)
Taking Advantage of IDEA
729(4)
Agile Java References 733(2)
Index 735

Supplemental Materials

What is included with this book?

The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.

The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.

Excerpts

Introduction Introduction I am a software craftsman. 1 I have spent much of my software development career trying to quickly build solutions to problems. At the same time I have tried to ensure that my solutions demonstrate carefully crafted code. I strive for perfection in code, yet I know that it is unattainable, particularly with the constant pressure from business to get product out the door. I take modest pride in the code I build daily, yet when I look at the code I wrote the day before, I wonder, "What the heck was I thinking?" This is what keeps the craft challenging to me--the constant desire to figure out how to do things a little better the next time, and with a little less pain than this time. Agile Java represents a successful approach to learning and mastering Java development. It is based on the way I have learned to best teach programming and to learn new programming languages myself: Using test-driven development (TDD), a technique that introduces a large amount of low-level feedback. This feedback allows you to more quickly see the results of your actions. Using TDD, you will learn how to craft Java code to produce solid object-oriented designs and highly maintainable high-quality systems. I have used TDD in production systems for over four years and am still amazed at what it does for me. It has improved the quality of my code, it has taught me new things each week, it has made me more productive. I have also created and taught language courses using TDD, both at my own company and at Object Mentor (which continues to teach their language courses with this approach). Prior to learning TDD, I spent more than fifteen years learning, developing in, and teaching languages the "classic" way--without using tests to drive the development. The student builds and executes example code. The student obtains feedback on what the code is teaching by viewing the output from code execution. While this is a perfectly valid approach, my anecdotal experience is that using it results in less-than-ideal retention of language details. In contrast, the high volume of rapid feedback in TDD constantly reinforces correct coding and quickly points out incorrect coding. The classic code-run-and-observe approach provides feedback, but at a much slower rate. Unfortunately, it is currently the predominant method of teaching programming. Others have attempted more innovative approaches to teaching. In the 1990s, Adele Goldberg created a product known as LearningWorks designed for teaching younger students. It allowed a user to directly manipulate visual objects by dynamically executing bits of code. The user saw immediate results from their actions. A recent Java training tool uses a similar approach. It allows the student to execute bits of code to produce visual effects on "live" objects. The problem with approaches like these is that they are bound to the learning environment. Once you complete the training, you must still learn how to construct your own system from the ground up, without the use of these constrained tools. By using TDD as the driver for learning, you are taught an unbounded technique that you can continue to use in your professional software development career. Agile Java takes the most object-oriented approach feasible. Part of the difficulty in learning Java is the "bootstrapping" involved. What is the minimum you must learn in order to be able to write classes of some substance? Most books start by teaching you the prototypical first Java program--the "hello world" application. But it is quite a mouthful: class Hello { public static void main(String args) { System.out.println("hello world"); } }. This brief program contains at least a dozen concepts that you must ultimately learn. Worse, out of those dozen co

Rewards Program