Cocoa Quick Start

(Thu Sep 18, 2008) [/Books#

I've been gearing up for some client work using Cocoa, and along the way I had the pleasure of being a tech reviewer for Daniel Steinberg's latest book Cocoa Programming: A Quick-Start Guide for Developers. I don't often review books here, but this book is exceptional. I think it has the potential to help folks who are interested in building native Mac (and iPhone) applications finally break into Cocoa development. The book was just released as a beta. Here's a rundown of what's inside and how it's been helpful to me.

After getting a quick lay of the land in the first chapter, Chapter 2 jumps right into building a simple web browser in Cocoa. That sounds fairly complicated for your first Cocoa app. I remember bracing for the unavoidable moment when I'd have to copy in a bunch of code I didn't understand. Thankfully, it's not that kind of book.

What I like most about this book is that it makes learning Cocoa fun and accessible. At the same time, I never felt like Daniel was waving his hands or dumbing anything down. He respected that I was a programmer, but didn't take advantage of that by making me wade through unfamiliar code to get to the good stuff. After all, a simple web browser in Cocoa is just a text field, a web view, and two buttons to navigate forward and back. You can lay out and wire up those components to act like a browser using Interface Builder without writing a single line of code. That's what the second chapter is all about: getting visual early! When I'm learning a new set of tools, I like to focus on one thing at a time. In this case, I was introduced to Interface Builder without having to tackle Objective-C, and I chalked up a quick win.

Of course, you'll need to write some code to make your web browser different from all the others. But again, you really don't want to stop and learn the entire Objective-C language just to add a new feature to the web browser. Chapter 3 is a gentle introduction to sending messages in Objective-C. If you've never seen the selector syntax, it can be a little awkward at first. The best way I've found to learn how it works is to start sending messages to existing Cocoa libraries. It turns out you can practice this in Interface Builder too. By the end of Chapter 3 my web browser and I were a little smarter.

Once you're comfortable with sending messages to existing objects, you're ready to create some Objective-C classes and objects of your own. Interface Builder can only do so much. Chapter 4 is where the rubber meets the road. Daniel walks you through creating a controller and how to make connections with Interface Builder through actions and outlets. I really like how he starts with a controller that's just a middleman, then incrementally expands its responsibility. It doesn't take a lot of Objective-C code, but it was just enough to make me feel comfortable creating classes with methods and instance variables. Daniel kept building up my confidence, one step at a time. And doing the exercises in each chapter kept me engaged.

Sending messages to a controller is one way to respond to user actions, but it's only part of the picture. In most Cocoa applications there's lot of stuff happening behind the scenes, too. The Cocoa frameworks can call back into your application via delegate methods and send notifications when certain things happen. Chapter 5 shows you how to use delegates and notifications to update the browser's title bar when a page finishes loading and update a progress bar as it's loading. Again, the process of building an application is driving what you need to learn, and when. That's exactly the way I like to new learn things.

At this point in the book I'm feeling pretty good about myself, and I'm really enjoying learning something new. I'm also surprised to find myself liking Objective-C. But I know that Daniel has been kindly delaying the topic of memory management until it's necessary, and it's been a few years since I've had to clean up after myself. The Cocoa event loop does a lot of this for you, and Objective-C 2.0 includes a garbage collector, but Cocoa applications often need to take more direct control (and iPhone apps always do). Chapter 6 steps away from the web browser to show you how to create objects with properties, and how to make them good stewards of memory. I suspect everyone has a slightly different mental model for understanding the retain-release cycle. This chapter was the first explanation of Objective-C memory management that really worked for me.

As this book is currently in beta, it's not yet complete. I'm very much looking forward to Daniel's new chapters as they come. That said, this beta book has already given me everything I need to start building my own Cocoa applications. And that's really the point. It's designed to get you up and running quickly, and help you through the first couple weeks of moving to Cocoa. To that end, I think Cocoa Programming: A Quick-Start Guide for Developers is simply brilliant!

Book Signing at RailsConf

(Fri May 23, 2008) [/Books#

If you'll be at RailsConf next week, there's an easy way to get your copy of Advanced Rails Recipes signed by a number of recipe contributors. (With over 50 contributors, it's a tad more difficult to hunt them down one by one.)

We've arranged a group book signing during the 12:35pm lunch break on Friday at the Powell's Books booth. We hope you'll stop by, get your book signed a bunch of times by these great Rails chefs, and just have fun!

Advanced Rails Recipes Is Shipping!

(Mon May 12, 2008) [/Books#

The paper book version of Advanced Rails Recipes is now shipping! If you bought the combo pack during beta (thanks!), you should be receiving your paper copy any day now if you haven't already. Dave surprised me with a copy at the beginning of a Studio last week. I'm really happy with the way everything turned out, and it feels good to finally have this one in circulation.

You might still be wondering what's inside the book. Reading the table of contents is a good start (and includes a couple freebies), but I thought you might also want to see a few recipes in action. So I put together a short (12 minute) screencast that highlights the results of 17 recipes with strong visual appeal. (Watch the screencast.)

Big shouts out to all the contributors! You guys rock.

Advanced Rails Recipes: Final Recipes

(Sun Mar 02, 2008) [/Books#

Advanced Rails Recipes is recipe-complete! I snuck four more into the fourth beta revision that was released today, for a final total of 84 recipes. That's a good round number, and this puppy needs to go to print soon, so the kitchen is officially closed. :-)

Here's what's new:

  • Send Lightweight Messages (using Starling)

  • Nest Resources to Scope Access

  • Automate Periodic Tasks

  • Encrypt Sensitive Data

Thanks for submitting errata! We worked the list down for this beta revision, and added a few new things here and there to the existing recipes based on your input. For example, we expanded the Solr recipe to include more information on the solr-ruby library. We also addressed a few corner cases in the multi-model form recipe. Finally, we thought nested routes deserved their own recipe. So we expanded nested routes into a new recipe in this revision, and added a :member example to the recipe on adding custom RESTful routes to keep it focused on non-nested routes.

Please keep the errata coming. The book will go into production (copyedit, indexing, layout, etc.) in a week, and I'd really appreciate a good scrub of all the recipes. If you only have time to read through a couple, please go straight for the shiny new ones.

Thanks again for your continued support!

Advanced Rails Recipes +14

(Tue Feb 26, 2008) [/Books#

That's 14 more get 'er done recipes, for a total of 81 in the third beta revision of Advanced Rails Recipes. Yeah, I know I promised 72 recipes. Sorry 'bout that. Y'all just kept sending me more, and they were so good I simply couldn't resist. Anyway, I hope you enjoy the extras.

Here's what's new:

  • Process Recurring Credit Card Payments

  • Support An iPhone Interface

  • Send E-mail via Gmail

  • Segregate Page Cache Storage with Nginx

  • Build a Sitemap

  • Full-Text Search with Sphinx

  • Customize Error Messages

  • Load Balance Around Your Mongrels' Health

  • Quick & Dirty Search

  • Use Fixtures For Canned Datasets

  • Cheap & Easy Caching (requires Edge Rails)

  • Drive a Feature with Integration Tests

  • Write Domain-Specific RSpec Matchers

  • Use DTrace for Profiling

Current recipe contributors include: Aaron Batalion, Adam Keys, Andre Lewis, Andrew Kappen, Ben Smith, Chris Bernard, Chris Haupt, Chris Wanstrath, Cody Fauser, Dan Benjamin, Dan Manges, Daniel Fischer, David Chelimsky, Erik Hatcher, Ezra Zygmuntowicz, Geoffrey Grosenbach, Giles Bowkett, Greg Hansen, Gregg Pollack, Hemant Kumar, Hugh Bien, Jamie Orchard-Hays, Jared Haworth, Jarkko Laine, Jason LaPier, Jay Fields, John Dewey, Jonathan Dahl, Josep Blanquer, Josh Stephenson, Josh Susser, Kevin Clark, Luke Francl, Mark Bates, Marty Haught, Matthew Bass, Michael Slater, Mike Hagedorn, Mike Mangino, Mike Naberezny, Mike Subelsky, Nathaniel Talbott, PJ Hyett, Patrick Reagan, Peter Marklund, Pierre-Alexandre Meyer, Ryan Bates, Scott Barron, Sean Mountcastle, Tony Primerano, and Warren Konkel.

Now, don't tell my editor (Hi, Dave!), but I may end up sneaking a couple more juicy recipes into the final revision. They're already in progress, but not quite ready for the beta.

The book will go into production (copyedit, layout, etc.) very soon, so if you notice any problems and things that could use a bit more clarification, I'd really appreciate it if you'd file errata. I'll work 'em all off for the final revision.

Thanks to all the contributors for their fantastic work!