More on Learning Cocoa

As I stated in yesterday’s article, Learning Cocoa, I’m struggling with the syntax of Objective-C. It’s not that I don’t understand it, it’s just completely different looking than C-derived syntax like Java, C++, C#, and php (the languages I use in “real-life”).

To add to the problem, I’m struggling with style. What I mean here is how to layout the code as I write it. What is the best way to use blank space and comments to full effect? How to name my functions so that they are easy to read and type, etc.

I’ve been following Wil Shipley’s site as he critique’s people’s code for style and best practices. This has been pretty helpful, but not quite the same as having a mentor to look over your shoulder.

So far, the best hope I’ve had is deeming insight from the books I’m reading and any example code I find. Short of that, I’ve been experimenting as I write my code.

For example, I have an initialize method on my Player class. I’ve played with two ways of calling the method. Which format looks easier to read to you?

This may seem like a small thing, but what happens when you have pages upon pages of code? Does your code get messy and hard to read? Right now I’m leaning towards the multi-line style, but Wil Shipley has been recommending everything on one line. Maybe as I get used to looking at Objective-C, I’ll agree with him.