“Next time some kid shows up at my door asking for a code review, this is the book that I am going to throw at him.”
–Aaron Hillegass, founder of Big Nerd Ranch, Inc., and author of Cocoa Programming for Mac OS X
Unlocking the Secrets of Cocoa and Its Object-Oriented Frameworks
Mac and iPhone developers are often overwhelmed by the breadth and sophistication of the Cocoa frameworks. Although Cocoa is indeed huge, once you understand the object-oriented patterns it uses, you’ll find it remarkably elegant, consistent, and simple.
Cocoa Design Patterns begins with the mother of all the Model-View-Controller (MVC) pattern, which is central to all Mac and iPhone development. Encouraged, and in some cases enforced by Apple’s tools, it’s important to have a firm grasp of MVC right from the start.
The book’s midsection is a catalog of the essential design patterns you’ll encounter in Cocoa, including
Fundamental patterns, such as enumerators, accessors, and two-stage creation Patterns that empower, such as singleton, delegates, and the responder chain Patterns that hide complexity, including bundles, class clusters, proxies and forwarding, and controllers And that’s not all of them! Cocoa Design Patterns painstakingly isolates 28 design patterns, accompanied with real-world examples and sample code you can apply to your applications today. The book wraps up with coverage of Core Data models, AppKit views, and a chapter on Bindings and Controllers.
Cocoa Design Patterns clearly defines the problems each pattern solves with a foundation in Objective-C and the Cocoa frameworks and can be used by any Mac or iPhone developer.
This book bills itself as a Cocoa-equivalent to the origin "Design Patterns" book. While you can read it that way, I found it most rewarding when looking for answers as to why things are the way they are in Cocoa. This was closer to what I was hoping for—less of a classic patterns book, more of a guide to Cocoa idioms and the rationale behind them.
My copy was completely dog-eared and full of notes in the two weeks it took me to read this. For an experienced developer coming to Cocoa or Cocoa Touch from other platforms, this is an essential guide to getting to the philosophy that underlies Objective-C and Cocoa.
Let me just start by saying that mine is an unfair rating for this book. The description is accurate and I couldn't fault the author's style or delivery. I also judge without finishing it, I stopped reading half way in.
However, "barely two starts worth" is how much value I've gotten from this book. An experienced developer just won't learn much by reading this book. It is a list of patterns that most of us have used before, with explanation and justification for each. The fact that they are found in Cocoa is entirely inconsequential.
Being able to attach a label to a pattern that you have used is useful for conversation. Reading about patterns, on the other hand, is a useless exercise that just wont make you a better developer.
From the (again to be fair, accurate) description "professionals will be able to effectively re-use the tried-and-true patterns in their own software." Professionals just do not need this book to re-use patterns and the fact that they are tried-and-true means that we have heard of them.
So while the book deserves a higher rating, I'd caution anybody against similar text. If you find the idea of this book appealing, go write some software instead.
Fantastic book. This is the way I learned to program iPhone apps.
The problem with cookbooks and language references is their impracticality in the real world. This book avoids that problem by providing real examples of patterns you might use in a production app.
For example, you use a Singleton for a central database or user save data, because you want it to serve as the single ground truth for all queries across your app.
You use the Decorator pattern for ornaments on your keyboard when it comes up, adding buttons for Cancel and Confirm.
Likewise, many patterns have natural analogs in the world of Objective-C: - The Flywheel pattern for collections generating cells upon themselves. - The Delegate pattern for callbacks to parent ViewControllers when a child view needs info. - The Composition pattern for building classes that contain encapsulated, archivable data like your custom strings, user profiles, and dictionary values. - The Singleton pattern for central databases and save data. - The Decorator pattern for keyboards, supplemental views, callouts, and toolbars. - The Model-View-Controller pattern for storing data in models, UI in views, and response logic in controllers - The Observer pattern for responding to backgrounding of the app, returning from background or sleep, hearing back from REST API servers - The Dispatch pattern for performing UI work on the main thread, other work on other threads
+ the big plus of this book is that it is the only book dedicated to design patterns in combination with mac programming. one would expect to find more books like that, given the fact that objective-c and cocoa are so "pattern-friendly" and "pattern-oriented". only when i came to objective-c and cocoa did i learn how to solve those design problems that have always haunted me in java and c++. what would feel awkward to program in other languages is the most natural thing in objective-c. i might now be able to transfer the way i program in objective-c to those other languages, knowing that it is not my design that is awkward but those other languages. the book solidified that eye-opening experience and is a way to learn about patterns even if you come from a different language and platform.
on the downside: - the book is out of date and needs an updated edition. the code examples don't use ARC, which confines readability. ARC would simplify the code and help illustrating the patterns. also, some patterns are just programmed differently with arc. - the book should go for Cocoa touch. one reason is that cocoa touch is more modern and simpler and lets the patterns stand out more. - the structure of the book is not convincing. to me "solution" is not the proper follower on "motivation". also, the author tried to structure the text on each pattern in the same way to be consistent. but he does not manage to fill the structure properly. after reading some patterns you realise that the section titles are rather meaningless. It does not seem appropriate for a book on design patterns to be so poorly structured. - the writing is average at best and far too redundant for my taste
well, this book is not suited to be read from start to finish. it has no overarching "story" to it and the writing is dry and redundant. it should be used as a reference.