|Amazon Price||New from||Used from|
Kathy Sierra has been interested in learning theory since her days as a game developer (Virgin, MGM, Amblin'). More recently, she's been a master trainer for Sun Microsystems, teaching Sun's Java instructors how to teach the latest technologies to customers, and a lead developer of several Sun certification exams. Along with her partner Bert Bates, Kathy created the Head First series. She's also the original founder of the Software Development/Jolt Productivity Award-winning javaranch.com, the largest (and friendliest) all-volunteer Java community.
Bert Bates is a 20-year software developer, a Java instructor, and a co-developer of Sun's upcoming EJB exam (Sun Certified Business Component Developer). His background features a long stint in artificial intelligence, with clients like the Weather Channel, A&E Network, Rockwell, and Timken.
I was told there would be objects. In chapter 1, we put all of our code in the main() method. Thats not exactly object-oriented. In fact, thats not object-oriented at all. Well, we did use a few objects, like the String arrays for the Phrase-O-Matic, but we didnt actually develop any of our own object types. So now weve got to leave that procedural world behind, get the heck out of main (), and start making some objects of our own. Well look at what makes object-oriented (OO) development in Java so much fun. Well look at the difference between a class and an object. Well look at how objects can give you a better life (at least the programming part of your life. Not much we can do about your fashion sense). Warning: once you get to Objectville, you might never go back. Send us a postcard.
(or How Objects Can Change Your Life)
Once upon a time in a software shop, two programmers were given the same spec and told to "build it". The Really Annoying Project Manager forced the two coders to compete, by promising that whoever delivers first gets one of those cool Aeron chairs all the Silicon Valley guys have. Larry, the procedural programmer, and Brad, the OO guy, both knew this would be a piece of cake.
Larry, sitting in his cube, thought to himself, "What are the things this program has to do? What procedures do we need? And he answered himself, "rotate and playSound." So off he went to build the procedures. After all, what is a program if not a pile of procedures?
Brad, meanwhile, kicked back at the café and thought to himself, "What are the things in this program... who are the key players?" He first thought of The Shapes. Of course, there were other objects he thought of like the User, the Sound, and the Clicking event. But he already had a library of code for those pieces, so he focused on building Shapes. Read on to see how Brad and Larry built their programs, and for the answer to your burning question, "So, who got the Aeron?
In Larrys cube
As he had done a gazillion times before, Larry set about writing his Important Procedures. He wrote rotate and playSound in no time.
// make the shape rotate 360º
// use shapeNum to lookup which
// AIF sound to play, and play it
At Brads laptop at the cafe
Brad wrote a class for each of the three shapes
Larry thought hed nailed it. He could almost feel the rolled steel of the Aeron beneath his...
But wait! Theres been a spec change.
"OK, technically you were fi rst, Larry," said the Manager, "but we have to add just one tiny thing to the program. Itll be no problem for crack programmers like you two."
"If I had a dime for every time Ive heard that one", thought Larry, knowing that specchange-no-problem was a fantasy. "And yet Brad looks strangely serene. Whats up with that?" Still, Larry held tight to his core belief that the OO way, while cute, was just slow. And that if you wanted to change his mind, youd have to pry it from his cold, dead, carpal-tunnelled hands
Back in Larrys cube
The rotate procedure would still work; the code used a lookup table to match a shapeNum to an actual shape graphic. But playSound would have to change. And what the heck is a .hif fi le?
// if the shape is not an amoeba,
// use shapeNum to lookup which
// AIF sound to play, and play it
// play amoeba .hif sound
It turned out not to be such a big deal, but it still made him queasy to touch previously-tested code. Of all people, he should know that no matter what the project manager says, the spec always changes.
At Brads laptop at the beach
Brad smiled, sipped his margarita, and wrote one new class. Sometimes the thing he loved most about OO was that he didnt have to touch code hed already tested and delivered. "Flexibility, extensibility,..." he mused, reflecting on the benefits of OO
Larry snuck in just moments ahead of Brad.
(Hah! So much for that foofy OO nonsense). But the smirk on Larrys face melted when the Really Annoying Project Manager said (with that tone of disappointment), "Oh, no, thats not how the amoeba is supposed to rotate..."
Turns out, both programmers had written their rotate code like this:
1) determine the rectangle that surrounds the shape
2) calculate the center of that rectangle, and rotate the shape around that point.
But the amoeba shape was supposed to rotate around a point on one end, like a clock hand.
"Im toast." thought Larry, visualizing charred Wonderbread. "Although, hmmmm. I could just add another if/else to the rotate procedure, and then just hard-code the rotation point code for the amoeba. That probably wont break anything." But the little voice at the back of his head said, "Big Mistake. Do you honestly think the spec wont change again?"
Bought for university classes. It is a decent book. Helped me out sometimes for references and tasks but I didn't use it often as I hoped. Read morePublished 25 days ago by Daniel
Great way of teaching OO to those who have little to no experience with itPublished 26 days ago by Ms T M Brothwell
This has to be the worst way possible to learn a Programming Language. From the outset you're treated like an idiot and as you go along the assumptions made are impossible to... Read morePublished 2 months ago by wardie2437
I wish I'd read the other one-star reviews before I bought this very disappointing book. They all sum up my feelings about it - "frivolous", "vacuous",... Read morePublished 4 months ago by A G Ward
Good but dated. Hello Head First team, have you notice we're in Java 8? This book is for Java 5. So many things have changed since then. Read morePublished 4 months ago by maikeladas
The head first series is superb, this is the third book I have bought from this seriesPublished 5 months ago by JohnDoe