Thursday, December 18, 2008

Going to be Objective

I just finished reading the Objective-C book. As, I said in an earlier post, I'm a believer. I will list what I like and don't like about the language. First the "Likes,"...

LIKES:

Archiving
Categories
Dynamic Binding
Fast Enumeration
Garbage Collection (caveat here)
Posing
Protocols

Dislikes:

Containers and the built in reference counts when accessing object elements
Memory management (retaining, releasing, dealloc-ing)

See the caveat in the "Likes," list next to Garbage Collection it is there because the iPhone does not support Garbage Collection, thus my "Dislikes," come into play. You have to be extremely careful and mindful of Object creation and use in Objective-C. In C++ you have to as well, but you can encapsulate it with the use of the Design Pattern, Singleton or with the STL auto_ptr or Booost's smart pointers. I'm going to have to be like Luke, in "Cool Hand Luke," and get my mind right, ("You run one time, you got yourself a set of chains. You run twice you got yourself two sets. You ain't gonna need no third set, 'cause you gonna get your mind right.")

I really like Dynamic Binding and Archiving. The two used together equals built in "Reflection, (somewhat)."

Well, the journey continues. I will now read up on Cocoa and make note of the differences between Mac and iPhone programming, since my game level editor and tools will be written to run on the Mac, and the game engine will be running on the iPhone. The game engine will be data-driven, but I want to be able to have the level editor be able to play test the levels in real-time, so the game engine will be leveraged to run inside the editor. This means I'll have some code that is specific to iPhone, and Mac OS X, i.e., OpenGL (running OGL ES on iPhone), and the UI objects will be utilizing different frameworks. So, I will have to make note of the differences, and have preprocessor directives to block out certain spots of code that I don't want compiled in.

Yes, Yes, I could write code with pattern(s) that could tell what environment I was running on and then set the behavior to fit, but the foot print of the iPhone is smaller so why compile in the excess baggage.

No comments: