Items related to Head First Java

Sierra, Kathy; Bates, Bert Head First Java ISBN 13: 9781600330001

Head First Java - Softcover

 
9781600330001: Head First Java

This specific ISBN edition is currently not available.

Synopsis

An interactive guide to the fundamentals of the Java programming language utilizes icons, cartoons, and numerous other visual aids to introduce the features and functions of Java and to teach the principles of designing and writing Java programs.

"synopsis" may belong to another edition of this title.

About the Author

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.

Excerpt. © Reprinted by permission. All rights reserved.

Chapter 2 A Trip to Objectville

I was told there would be objects. In chapter 1, we put all of our code in the main() method. That’s not exactly object-oriented. In fact, that’s not object-oriented at all. Well, we did use a few objects, like the String arrays for the Phrase-O-Matic, but we didn’t actually develop any of our own object types. So now we’ve got to leave that procedural world behind, get the heck out of main (), and start making some objects of our own. We’ll look at what makes object-oriented (OO) development in Java so much fun. We’ll look at the difference between a class and an object. We’ll 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.

Chair Wars
(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 Larry’s cube
As he had done a gazillion times before, Larry set about writing his Important Procedures. He wrote rotate and playSound in no time.

rotate(shapeNum) {
// make the shape rotate 360º
}
playSound(shapeNum) {
// use shapeNum to lookup which
// AIF sound to play, and play it

At Brad’s laptop at the cafe
Brad wrote a class for each of the three shapes

Larry thought he’d nailed it. He could almost feel the rolled steel of the Aeron beneath his...

But wait! There’s 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. It’ll be no problem for crack programmers like you two."

"If I had a dime for every time I’ve heard that one", thought Larry, knowing that specchange-no-problem was a fantasy. "And yet Brad looks strangely serene. What’s 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, you’d have to pry it from his cold, dead, carpal-tunnelled hands

Back in Larry’s 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?

playSound(shapeNum) {
// if the shape is not an amoeba,
// use shapeNum to lookup which
// AIF sound to play, and play it
// else
// 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 Brad’s 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 didn’t have to touch code he’d 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 Larry’s face melted when the Really Annoying Project Manager said (with that tone of disappointment), "Oh, no, that’s 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.

"I’m 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 won’t break anything." But the little voice at the back of his head said, "Big Mistake. Do you honestly think the spec won’t change again?"

"About this title" may belong to another edition of this title.

(No Available Copies)

Search Books:



Create a Want

Can't find the book you're looking for? We'll keep searching for you. If one of our booksellers adds it to AbeBooks, we'll let you know!

Create a Want

Other Popular Editions of the Same Title

9780596009205: Java : Head First

Featured Edition

ISBN 10:  0596009208 ISBN 13:  9780596009205
Publisher: O'Reilly Media, Inc, USA, 2005
Softcover