Customer Reviews


41 Reviews
5 star:
 (31)
4 star:
 (3)
3 star:
 (3)
2 star:
 (3)
1 star:
 (1)
 
 
 
 
 
Average Customer Review
Share your thoughts with other customers
Create your own review
 
 

The most helpful favorable review
The most helpful critical review


102 of 105 people found the following review helpful
5.0 out of 5 stars Ooh. Ow. Ouch. Eek. Argh. ... Aha.
My wife popped this book open after dinner. Big mistake -- we had planned to spend the night watching Firefly on DVD. She read the first puzzle. We went to the blackboard (yes, we're so geeky and our NY apartment's so small that there's a blackboard in the dining nook). Between us, we had half a dozen possible answers about what a three-line program was going to do...
Published on November 22, 2005 by Bob Carpenter

versus
9 of 9 people found the following review helpful
3.0 out of 5 stars Not really a puzzles book
I picked up this book after being asked a question from it in an interview (actually, I was unaware it was from this book until browsing through it at a bookstore).

It's quite an interesting read, even for seasoned java programmers. There's a lot of little quirks and oddness in the Java specification that one rarely encounters in the real world - for good...
Published on December 28, 2009 by J.S.R.


‹ Previous | 1 25 | Next ›
Most Helpful First | Newest First

102 of 105 people found the following review helpful
5.0 out of 5 stars Ooh. Ow. Ouch. Eek. Argh. ... Aha., November 22, 2005
By 
Verified Purchase(What's this?)
This review is from: Java Puzzlers: Traps, Pitfalls, and Corner Cases (Paperback)
My wife popped this book open after dinner. Big mistake -- we had planned to spend the night watching Firefly on DVD. She read the first puzzle. We went to the blackboard (yes, we're so geeky and our NY apartment's so small that there's a blackboard in the dining nook). Between us, we had half a dozen possible answers about what a three-line program was going to do. We found at least four boundary conditions and were pretty sure about two of them. For the record, the first puzzle she opened to involved the compound XOR assignment statement x^=y^=x^=y. They're not all that bit-fiddly; some of the other puzzles include class and method mazes, integer or double arithmetic oddities, unexpected exception/initialization interactions, string/charset twistiness, etc.

I thought I'd be good at this kind of puzzle. As an academic, I wrote about programming languages. I read Bloch's "Effective Java" book. Twice. I follow its advice religously and make my coworkers read it. I've read most of the source code for String, StringBuffer and the collections framework and I/O streams. I just came off a week-long coding project where I did exclusively bit-level I/O with all the shifts and masks you could ask for. I was wrong. I got about 1/5 of the puzzles right if I give myself partial credit for diagnosing the boundary condition in the question and having the right answer be in my top two or three guesses.

Unless you've written the bit fiddling parts of a JVM implementation, or are the kind of person who can remember minute details of the specification, you'll most likely suffer. And love it. Then you can relate the puzzles at gatherings of geeks and look on with a smug grin as they twist in the wind. These would be perfect interview questions for a sadistic HR person.

Overall, this book's a jaw-dropping, eye-opening, brain-melting overview of the kind of boundary conditions you can run into with very simple constructions. Most of the puzzles seem to involve implicit conversions done by the JVM, some involve 1.5 features, some involve class inheritance, others exceptions. Almost all of the puzzles contain links to the boundary-condition definition in the Java language spec.

I'll do better next time. Really.
Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No


28 of 29 people found the following review helpful
5.0 out of 5 stars Unique book finds pitfalls in both programs and the language itself, May 26, 2006
This review is from: Java Puzzlers: Traps, Pitfalls, and Corner Cases (Paperback)
This book is filled with brainteasers about the Java programming language and its core libraries. Anyone with a working knowledge of Java can understand these puzzles, but many of them are tough enough to challenge even the most experienced programmer. Puzzlers are grouped according to the features they use, but you cannot assume that the trick to a puzzle is related to its chapter heading.

Most of the puzzles exploit counterintuitive or obscure behaviors that can lead to bugs. Every platform has them, but Java has far fewer than other platforms of comparable power. The goal of the book is to entertain the reader with puzzles while teaching you to avoid the underlying traps and pitfalls. By working through the puzzles, you become less likely to fall prey to these dangers in your own code and more likely to spot them the code of others over which you have maintenance priveleges.

This book is meant to be read while you have access to a computer that has a Java development environment installed, ideally JDK 5.0, which is the latest release at the time I am writing this. That is because some of the puzzles rely on pitfalls in this particular release of Java.

Most of the puzzles take the form of a short program that appears to do one thing but actually does something else. It's the reader's job to figure out what each program does. It would be best if you first study the program/puzzle and determine what you think it will do. Next, run the program and see if its expected behavior matches its actual behavior. Try to fix the program if you believe it is "broken". Finally, read the solution and see if it matches your answer. What is really great about this book is that it sticks to pitfalls in the core language and doesn't delve into any of the add-on API's or J2EE. You'll be surprised that so many pitfalls can be conjured up in the core language. Amazon does not show the table of contents, so I do that here along with a brief description of the type of puzzles in each chapter.

1. Introduction
2. Expressive Puzzles - The puzzles in this chapter are simple but not necessarily easy and involve only expression evaluation. My personal favorite : the statement "System.out.println(2.00 - 1.10);" displays 0.8999999999999999 instead of .9. There is a solution, but it is not pretty and showcases a pretty bad weakness in the Java language.
3. Puzzlers with Character - This chapter contains puzzles that concern strings, characters, and other textual data. This section contains several puzzles involving unicode characters, and one is a cautionary tale for language designers in character overloading. Example: System.out.print('H' + 'a'); prints the number 169 not the word "Ha" as you might imagine.
4. Loopy Puzzlers - All the puzzles in this chapter concern loops, such as coming up with declarations that turn simple loops into infinite ones.
5. Exceptional Puzzlers - The puzzles in this chapter concern exceptions and the closely related Try-finally statement. Most exhibit odd behavior such that simple changes in the program cause completely different types of exception handling to occur.
6. Classy Puzzlers - This chapter contains puzzlers that concern the use of classes and their instances, methods, and fields.
7. Library Puzzlers - The puzzles in this chapter concern basic library-related topics, such as Object methods, collections, Date, and Calendar. One particularly interesting puzzler illustrates that, in Java, integer literals beginning with a "0" are interpreted as octal values. This obscure construct is a holdover from the C programming language and the 1970s, when octal was much more commonly used than today. Thus "012" is seen by Java as 10 base 10.
8. Classier Puzzlers - The puzzles in this chapter concern inheritance, overriding, and other forms of name reuse.
9. More Library Puzzlers - The puzzles in this chapter feature more advanced library topics, such as threading, reflection, and I/O. Here you will learn, for example, that "write(int)" is the only Java output method that does not flush a PrintStream on which automatic flushing is enabled. Thus you must explicitly invoke "flush" on its stream to print any message, making the "write" method seem unfriendly and outright pointless.
10. Advanced Puzzlers - The puzzles in this chapter concern advanced topics, such as nested classes, generics, serialization, and binary compatibility.
A. Catalog of Traps and Pitfalls - This chapter contains a concise taxonomy of traps and pitfalls in the Java platform. Each entry in the catalog is divided into three parts - A short description of the pitfall, how to avoid the trap, and pointers to additional information on the trap.
B. Notes on the Illusions - This appendix contains brief descriptions of the graphical illusions that appear throughout the book. The descriptions are grouped loosely by category. Within each category, the order is roughly chronological.

This book is very good practice for anybody who enjoys programming in the Java language, but it will probably appeal the most to the geekiest among us of which I proudly count myself.
Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No


18 of 18 people found the following review helpful
5.0 out of 5 stars Most Excellent, July 15, 2005
This review is from: Java Puzzlers: Traps, Pitfalls, and Corner Cases (Paperback)
Many C and C++ books exist that discuss traps and pit falls with each language. Now Java has such a book. This book is fun to read and will challenge even the best Java programmers. Be sure to get the source code from [...] Study each puzzle and try figure out what it does or does not do. Then run the example code and see if you were right. If you weren't right, then try to figure out why you guessed wrong and figure out how to fix the program. Then turn the page and read the solution.

Working through the puzzlers is not only fun, but it will definitely make you a much better Java programmer and a better troubleshooter.
Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No


13 of 13 people found the following review helpful
5.0 out of 5 stars Wonderful stretches for your Java-soaked brain, July 14, 2005
This review is from: Java Puzzlers: Traps, Pitfalls, and Corner Cases (Paperback)
I've been passing this book around my office, describing it alternately as "C Traps and Pitfalls on steroids" or "The most fun that can be had with the Java Language Specification with your clothes on." Thus far, it has not failed to frustrate, educate, enlighten, and amuse each reader, usually in that order. I can't think of any better way to become more familiar with the ins, outs, and warts of the Java language: the puzzles, memorable and clever as they are, stick with you.

The writing is fluid, friendly, and full of wit, from the names of the puzzles (like "The Lock Mess Monster" or "Dyslexic Monotheism") to the commentary on the finer points. Even the layout shows thought, with the answers out of plain sight behind the next page.

If your brain burns out on the puzzles, check out the optical illusions in between. (Note: do not, during a car ride, show them to anyone who is prone to motion sickness. I learned this the hard way, so you don't have to.)

I strongly recommend this book if you spend any time in or around Java code. I've had to deal with many of the pitfalls it highlights, and boy, would it have been more pleasant if I'd already read this book.
Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No


9 of 9 people found the following review helpful
3.0 out of 5 stars Not really a puzzles book, December 28, 2009
This review is from: Java Puzzlers: Traps, Pitfalls, and Corner Cases (Paperback)
I picked up this book after being asked a question from it in an interview (actually, I was unaware it was from this book until browsing through it at a bookstore).

It's quite an interesting read, even for seasoned java programmers. There's a lot of little quirks and oddness in the Java specification that one rarely encounters in the real world - for good reason, as many of these things should be avoided like the plague. Examples are unicode pre-parsing and passing nulls into overloaded methods with same number of arguments.

If you're looking for logic puzzles, look elsewhere. The title would be more accurate with "puzzlers" removed. This is about the intricacies and flaws of the language. It's more academic than practical. Unless, of course, you're asked an interview question from it.
Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No


17 of 20 people found the following review helpful
5.0 out of 5 stars Geek fun!, November 18, 2005
This review is from: Java Puzzlers: Traps, Pitfalls, and Corner Cases (Paperback)
First, let's get this out of the way: you're not as smart as you think you are. Seriously. You don't know everything about Java. It's possible, however, that these authors do.

"Java Puzzlers" shows you more tricky corners of the Java language than you ever expected could exist. Not odd behaviors of obscure API classes, not failings of a particular implementation, but known consequences of the language specification itself. Each puzzler, written in an engaging and often humorous style, gives you a chance to figure things out for yourself before lowering the boom to let you know that, once again... you're wrong.

If you read this book and take its message to heart, you'll learn to avoid the dark alleys of Java, making sure your programs will never inadvertently become puzzlers for you or those who come after you.
Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No


6 of 6 people found the following review helpful
5.0 out of 5 stars Think you know Java? Think again., July 19, 2005
By 
Michael (CHARLOTTE, MI, United States) - See all my reviews
(REAL NAME)   
This review is from: Java Puzzlers: Traps, Pitfalls, and Corner Cases (Paperback)
Is your copy of Effective Java tattered and torn from overuse? Give it a break and sink your teeth into this book. The puzzles are guaranteed to enlighten and educate. If you want to push the envelope of your Java knowledge; this book is for you.

These puzzles are not just for fun. Many of the submitted puzzles have come from Java developers encountering bugs in their programs. Each puzzle provides a clear solution with detailed explanations of the what, where, and why for each case. Josh and Neal have done a great job of assembling and organizing almost a hundred such cases.
Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No


6 of 6 people found the following review helpful
5.0 out of 5 stars What? Aha..... Uh-oh!, August 2, 2005
By 
Tudor Har (Santa Clara, California) - See all my reviews
(REAL NAME)   
This review is from: Java Puzzlers: Traps, Pitfalls, and Corner Cases (Paperback)
"What is going on here? Aha, I think I got it. Uh-oh, the output is not what I expected."

This is what often happened when I was reading and running the code from this book. If you think you know Java well, prove it by going thru this book. It will surely make you go and look again at the Java Language Specification; you learn, relearn and never cease wondering how the authors came up with some of these examples. A gem of a book, it's so interesting that it makes you turn pages, one after another, late into the night. Highly recommended!
Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No


5 of 5 people found the following review helpful
5.0 out of 5 stars Stretch your mind and question your assumptions..., November 19, 2005
This review is from: Java Puzzlers: Traps, Pitfalls, and Corner Cases (Paperback)
This is the type of book I'd like to see more of in the marketplace... Java Puzzlers - Traps, Pitfalls, and Corner Cases by Joshua Bloch and Neal Gafter. Extremely well-done...

Contents: Introduction; Expressive Puzzlers; Puzzlers with Character; Loopy Puzzlers; Exceptional Puzzlers; Classy Puzzlers; Library Puzzlers; Classier Puzzlers; More Library Puzzlers; Advanced Puzzlers; Catalog of Traps and Pitfalls; Notes on the Illusions; References; Index

What Bloch and Gafter have done here is provide the Java coder with some educational opportunities unlike others. They've taken code blocks that look like they should do one thing, but actually do something entirely different. It's the job of the reader to figure out what they *really* do, why they behave that way, and how you'd change the code to get the result you were probably after. The material covers the gamut of normal Java scenarios, including string concatenation, looping, class definitions, and others. The code is available for download from a website, so you don't have to type in anything to get started. And of course, they *do* provide answers... :) Couple all this great material with a humorous writing style and fun optical illusions, and you've got a book that works very well.

The reason I like this book so much is that most programming language books stick to the core material. We all know there are exceptions and quirks, but you normally don't find out about those unless you find a magazine article series that someone has written. Even then, you're getting one or two gems every month, and it's hard to keep the momentum. Having 95 of these puzzlers all in one place means that you can dive in and start wracking your brain at your own pace. I'd like to see this type of book for many other languages...

Most definitely recommended if you're a Java coder with any level of experience. You'll be forced to question things you've assumed in the past, and you'll come away a much better developer...
Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No


4 of 4 people found the following review helpful
5.0 out of 5 stars entertaining and essential Java resource, August 11, 2005
By 
J.J. Langr (United States) - See all my reviews
This review is from: Java Puzzlers: Traps, Pitfalls, and Corner Cases (Paperback)
Java Puzzlers is a wonderful book that demonstrates how easy it is to fall into one of the numerous traps or pits that the Java language has strewn about. Even expert level Java developers make many of the mistakes that Bloch and Gafter show you how to avoid in Java Puzzlers.

The book contains about 90 brief programs. The authors ask you to read each snippet, think through it, and determine what the output of each program should be. Each program is always carefully positioned on the bottom right hand side, so that you can't see the solution beginning on the next page.

The code snippets don't just represent cute little problems that you come across when deliberately attempting to code poorly or with obscurity (like the code examples you might see in a Java certification exam). Most examples look like code you might see (and that I see quite often) in a typical app, code that on the surface looks like it should work just fine.

Bloch and Gafter explain the cause for each interesting result. They then tell you "don't do that," and patiently explain how to improve your approach so as to produce the correct code.

I really enjoyed Java Puzzlers, and along with Bloch's Effective Java (and of course Agile Java), it's one of the few Java books I can universally recommend. It will definitely make you a better professional programmer if you take its lessons to heart. As someone who's developed in Java for almost 10 years and written a couple books on it, I can guarantee you that you'll learn quite a bit from this book. I certainly did.

The book is a fun and quick read, and for me it contained some very interesting "wow" moments. The optical illusions (and the brief discussion of them in the back of the book) add to the attractiveness of Java Puzzlers.

Most of the coding errors demonstrated in Java Puzzlers should never see the light of production day. Unfortunately, many of them do. My only suggestion for the book would've been to include a bit of emphasis on how comprehensive unit testing would help eliminate these defects as soon as they're introduced. But if you want to learn how to do that, you can always check out Agile Java.
Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No


‹ Previous | 1 25 | Next ›
Most Helpful First | Newest First

Details

Java Puzzlers: Traps, Pitfalls, and Corner Cases
Java Puzzlers: Traps, Pitfalls, and Corner Cases by Joshua Bloch (Paperback - July 4, 2005)
$49.99 $40.38
In Stock
Add to cart Add to wishlist
Search these reviews only
Send us feedback How can we make Amazon Customer Reviews better for you? Let us know here.