For a slight change I am going to review Beginning Mac Programming: Develop with Objective-C and Cocoa by Pragmatic Bookshelf. Over the last couple of weeks I have been reading through this book, trying out the methods and tutorials, as a result I now know a bit about programming for the Mac. The book is designed to teach you the basics about programming for the Mac and show you pointers to get yourself start on what is a long journey on learn how to program. Within this post i’ll go over the main topics of the book, explain the pro’s and con’s and hopefully give you a good idea about the book itself.
If you have ever wanted to learn how to program it can be a daunting task. The code, the features of a program, XCode isn’t an easy program to learn by itself, as a result it can really hard to get into a programming language. This is where a book such as Beginning Mac Programming comes in. It’s set at people who have no programming experience at-all, so it teaches the basics on programming and puts in a context of using it on a Mac, I also think it is a good book for any one who wants to move into Objective-C and writing for the Mac platform. The book itself is around 400 pages when you take into account the appendices (352 pages is the official count), and each section is designed to help you learn and develop your skills.
No book would be complete without a simple step by step guide, or a way to “walk” through the book. This book is no different and is split into 14 main chapters. The contents are as follows and cover everything from a basic introduction all the way to loops and complex computer functions.
- Your First Application
- All About Objects
- Object Messaging
- Variables and Memory
- Passing Information Around
- Objects and Memory Management
- Collecting Information
- Branching Out
- Looping and Enumerating
- Objects, Encapsulation, and MVC
- All About Views
- Mac OS X and Cocoa Mechanisms
- Where to Go from here
- Developing for the iPhone
- Installing Xcode
The book breaks down learning Cocoa in simple steps, each developing on the previous chapters. The first chapter ” Your First Application”, introduces you to XCode and how an applications on a Mac works. It goes over XCode’s interface and shows you some of the main points of “main.m”. One of the files needed for a Mac app to work. Later in the chapter it develops basic Cocoa rules, which are used to display the interface you see. Near the end of the first chapter it will go into explaining how to build your first app. Through out the book you will be developing and extending your skills on an app called “TextApp”. It has no real function other than to explain and show you how things work on the Mac platform. By the end of the chapter you will have something that looks like the image below.
Not bad for your first Mac program. None of this “Hello World” stuff. A proper application. Admittedly it is a bit simple with just an area to write text, however making this app allows you to learn a lot about for XCode and Interface Builder works. You will be expanding on this app as you go through the book. The book itself isn’t designed to develop a specific application, but shows you all the different methods that can be found in most basic apps.
The second chapter introduces Objects, also known as Object Orientated Programming. This is where you can write a bit of code and then reference it from various parts of your applications. It is the basis of most programming languages. Within the chapter header and method files are introduced and explained there importance (they are very important). It promptly goes on to explain how to use them, and apply them to TextApp.
The next sections about Object Messaging, Variables and Memory and Passing Information Around, shows you how XCode and Object-C works with information and basic code. Each section is significant and the book explains why you should take note. After this Objects and Memory Management explains how to write good code so you don’t end up with errors a using lots of memory (which is both a good thing).
The final chapters Collecting Information, Branching Out, Looping and Enumerating all deal with loops and If statements found in most programming languages, if you have used other programming languages the basic features of programming are found here. Basic commands and statements which all programs employ. Each chapter takes the basic TextApp (which is more evolved than the image above) and allow it to become smarter and more of what you expect for an application. One of the first things you are introduced to is If statements. Your app displays different items of text when you enter a specific number. This technique is then developed further to boolean statements, so something happens when something is True or False, finally Case statements are used to define many operations, more which can be defined with just If statements. The book goes on to introduce dialogue warning boxes and lists with those little plus and minus boxes you see everywhere at the end of the chapters you will end up with something that looks like the image below.
The image above is a lot more complicated and developed than the first screens shot. If you have been paying attention to the code and the explanation you should know exactly what is happening and how to do it yourself. Within this book all of the background code is explained to you and more importantly why you are doing it.
The final chapters go into displaying information on screen and the Quartz software. If you develop more interactive apps, I can see how information learnt in this chapter would be used in other applications. As well as this there is a dedicated chapter for learning Cocoa and Mac Mechanisms so the applications you build are good Mac applications. There is also a chapter dedicated to showing you the basics on building an iPhone app. Nifty.
Within the back of the book is some of the most important piece of information. Included is ways to find more information including a bibliography and cool websites to visit. There is also information on how to install XCode, although you could just read my post about it.
The Low Down
Hopefully you have a good understanding of what’s in this book. I didn’t want to explain every little detail otherwise there would be no point in reading the book. If you want more information you can always read the excerpts. There are two available one on Passing Information Around and a second on Object Messaging. Both excerpts give you a good idea on what the final book is about although they are a bit short.
Most of the chapters at the beginning will take you about an hour depending on how quickly you work through them. The later chapters will take longer as there is more information within them and you deal with more complex topics. I recommend you learn from an actual book rather than an eBook or PDF as it will force you to write code rather than copy and paste it as I did with the pre-release eBook. By writing the code you get a better understanding of what is happening. Code wise you do go over and change the code a lot, however each change adds more complexity and hopefully you learn something new from it.
The book itself is written in a easy to understand with lots of analogies to help you understand some of the more difficult concepts, as a new user to Cocoa and Objective-C I understood what was happening and why we were doing it. I didn’t find any bits of code that didn’t work or didn’t work as intended, this is always a bonus for a book about coding. I’ve come across many books where the code you write doesn’t work.
Throughout the book there is plenty of images and steps for what you must do. Almost every action which involves you adding something to the project has an accompanying image. The code itself is written in a different font a colour to help you see what you should be writing. Code which you change is also bold and a different colour making it easier to understand what it happening. There is also plenty of tool tip boxes and foot notes to give you more information and understanding.
By the end of the book, I understood the basics of Objective-C and Cocoa including pointers objects and other features of the language. Although I do have some previous programming experience, Objective-C is new to me and did manage to understand a great deal of it by the end of the book.
The Not So Good
There is a couple of problems with this book that I must point out. The tool tip boxes and images are always at the top of the next page. Most of the time this isn’t a problem, however there is cases where you want to look at two images (which is explained in the text) and you have to go searching for them over the next couple of pages. This sort of breaks the flow of reading, since there is still blocks of text within below the images. At certain points you end up flicking back and forth a couple of times. Fortunately this doesn’t happen very often.
Another slight problem with this book is that some of the more complex topics seems to be slightly rush or not explained in full. It could just be me reading the book to fast, but at points I do feel like I am doing something for no reason. This, again, doesn’t happen very often but there is a couple of points within the book that I feel could have a bit more thought.
To conclude Beginning Mac Programming: Develop with Objective-C and Cocoa is a great book to get your started with learning to program Cocoa and Objective-C. It offers all of the basics and I feel I understand enough of the language to start playing around with it myself. The book refers to some basic concepts and backs them up with facts and ways to find out information on your own. There is numerous times where the official reference guide is called. This helps a lot when you want to write your own programs.
The book itself costs $23 if you buy is from Amazon, which is a bargain considering the depth and the amount of information contained within the chapters. By the end of it you should be wanting to learn more and build your own applications. By the end of it you will probably want to learn more. Further reading includes Cocoa Programming: A Quick-Start Guide which is a follow on book written by Pragmatic. Other books by different publishers include Learn Objective–C on the Mac (Learn Series) and Learn Cocoa on the Mac both by APress Books. There is plenty of information out there.
There you have it. Any one can learn programming I don’t it is that hard. Please leave a comment below with what you think. I hope that this post gives you a good insight into the book and what it contains. I definitely recommend it.