 |
Book Summary InformationAuthor: Mark Dalrymple, Scott Knaster Brand: Apress Edition: Paperback Audio: English (Unknown); English (Original Language); English (Published) Published: 2009-01-07 ISBN: 1430218150 Number of pages: 360 Publisher: Apress Product features: - Apress Learn ObjectiveC on the Mac
- Take your coding skills to the next level with this extensive guide to ObjectiveC, the native programming language for developing sophisticated software applications for Mac OS X.
Book Reviews of Learn Objective-C on the Mac (Learn Series)Book Review: Worst programming book I've ever read Summary: 1 Stars
Over the past three decades I've collected about fifty programming books, most of which deal with Unix, C and C++. I have read them all, and there are only two or three among them that I regard as poorly written. "Learn Objective-C on the Mac" is the very worst programming book I've ever encountered.
The best programming books are distinguished partly by the fact that the authors are meticulous with each and every sentence. This book is littered with sentences that do not quite make sense or that imply something contrary to the facts. On page 46, where they are discussing method declarations in the @interface section, they write, "The type of the argument is specified ... The name that follows, fillColor, is the parameter name. You use this name to refer to the parameter in the body of the method." This is incorrect. The name given to the parameter in the method definition, in the @implementation section, is used within the method to refer to the parameter, and this name is not required to match the name given to the parameter in the declaration in the @interface. Here's another example: "Although the draw method doesn't do anything, we define it anyway so that all of Shape's subclasses can implement their versions." This implies that you are not permitted to define a method in a subclass except for when that method overrides a method in the parent class. How about this pearl of wisdom: "You can make your code easier to read by choosing meaningful parameter names, rather than naming them after your pets or favorite superheroes."
The final five pages of Chapter 2 are spent discussing the type BOOL, which is implemented in a familiar way, using the C preprocessor. Several worthwhile things are covered in this discussion, the most pertinent of which is that it is generally a bad idea to perform a Boolean test via explicit comparison to 1, or equivalently, to a defined constant such as YES, which equates to 1. This is a worthwhile thing to discuss, but to spend as much as one full page on this is superfluous and tedious.
Chapter 3, which is titled "Introduction to Object-Oriented Programming", begins by asserting that indirection is a key concept of OOP. They spend several pages on an utterly sophomoric and incoherent discussion of indirection, after which they spend several more pages lecturing on how it is best not to embed, directly within a program, the data that a program operates on. Ten pages into the chapter, the large bold heading "Using Indirection in Object-Oriented Programming" appears. Two very short paragraphs into this section, the sub-heading "Procedural Programming" appears. Under this sub-heading, they devote no fewer than seven pages to the presentation of some C code for operating with graphical shapes. This C implementation is not realistic, because it avoids the use of pointers entirely, which contrasts with the normal practice in C of embedding function pointers within structures and passing around pointers to the structures. They then spend several pages on a parallel implementation in Objective-C, and at the very end of the chapter, they revisit the C implementation.
The premise of all this is that by contrasting the Objective-C implementation with the C implementation, they will demonstrate how indirection is a pivotal difference between procedural programming and OOP. The entire discussion amounts to a muddled contrivance. It does not remotely give a useful perspective on the difference between procedural programming and OOP. Indirection plays a role in OOP, but the notion that you could expose the essential difference by focusing on indirection is ludicrous. Their C implementation is contrived to facilitate their point of view. Their parallel implementation in Objective-C does not reflect a proper OOP implementation, because even though the various shape-specific classes have a great deal in common, they each descend immediately from NSObject. This is distracting, because if you have the slightest clue about OOP, you are aware that there is something inherently wrong with this implementation. They do it correctly in the next chapter, but in this chapter that is supposed to introduce OOP, the code they present confounds the true essence of object-oriented programming, under the guise of demonstrating that indirection is a key concept in OOP. The whole chapter is horrifically contrived and sophomoric.
Chapter 4 commences their discussion on inheritance. The diagrams they use to explain how methods are found at run-time are sophomoric. In the highlighted box on page 69 they talk about the memory layout of an object: "These offsets are now hard-coded into the program generated by the compiler. Even if Apple's engineers wanted to add another instance variable to NSObject, they couldn't, because that would change all the instance variable offsets. This is called the fragile base class problem." The problem to which they allude is nothing but the familiar and mundane requirement that if the base class changes, you have to recompile everything. The "fragile base class problem" is more fundamental. The trite example is what can occur if a derived class bypasses accessors to access instance variables defined in the base class. The cost of avoiding this is lots of run-time overhead, especially for Objective-C. The non-trite case is when a method, call it method A, invokes another method, call it method B. If a class that derives from the class where method A is defined extends method B, then the correctness of the behavior of this derived class is predicated on the assumption that when method A is invoked, the enhanced version of method B will be invoked. But if method A is subsequently modified such that it no longer relies on method B to do what it has done all along, the enhanced version of method B is no longer invoked when method A is invoked against the derived class, and the derived class is broken.
Chapter 5 deals with composition, i.e., using other classes as instance variables within a class. They discuss accessors in a cursory fashion toward the end of this chapter, but they do not delve into the semantics of dynamic allocation and deallocation of memory for the contained objects. The more significant problem with this chapter is that they switch to programming examples that are contrived and sophomoric, using cars, wheels and engines. This is so artificial that it is difficult to translate and apply what you the see in the example to real programming.
The book starts to improve with chapter 6, which begins on page 87. But the first five chapters take up more than one-fourth of a book that is just barely 300 pages, and even if what remains after page 87 were enough to justify a book, it would not make up for the dreadful way that the first five chapters are written.
Summary of Learn Objective-C on the Mac (Learn Series)Take your coding skills to the next level with this extensive guide to Objective?C, the native programming language for developing sophisticated software applications for Mac OS X. Objective?C is a powerful, object?oriented extension of C, making this book the perfect follow?up to Dave Mark?s bestselling Learn C on the Mac, Mac OS X Edition. Whether you?re an experienced C programmer or you?re coming from a different language such as C++ or Java, leading Mac experts Mark Dalrymple and Scott Knaster show you how to harness the powers of Objective?C in your applications! - A complete course on the basics of Objective?C using Apple?s free Xcode tools
- An introduction to object?oriented programming
- Comprehensive coverage of inheritance, composition, object initialization, categories, protocols, memory management, and organizing source files
- A brief tour of Cocoa?s foundation framework and AppKit
- A helpful ?learning curve? guide for non?C developers
What you?ll learn - Learn Objective?C programming, the gateway to programming your Mac or iPhone
- Write applications for the Mac OS X interface, the cleanest user?interface around
- Understand variables and how to design your own data structures
- Work with the file system
- Connect to data sources and the Internet
Who this book is for For anyone wanting to learn to program native applications in Mac OS X, including developers new to the Mac, developers new to Objective?C, or students entirely new to programming.
Computers & Internet Books
|
 |