views:

104

answers:

2

Cocoa is well-documented and there is a lot of information on writing Cocoa code in good form. I'm working on some code that works closely with hardware, requiring me to use CoreFoundation and Carbon APIs often. Is there any sort of 'style' guide for understanding libraries such as Carbon and CoreFoundation from Apple? Apple's example code is littered with things like:

  • kSomeValue
  • CFMightDoSomethingUseful

I can deduce that CF means CoreFoundation and k might be for constants or enumerated types, but I would like to verify this and learn more about the other syntactic styles.

+2  A: 

I can deduce that CF means CoreFoundation …

Specifically, it's the prefix for functions, types, and constants in the Core Foundation framework.

… and k might be for constants or enumerated types…

Yup. This one dates back all the way to the Toolbox days, before Core Foundation even existed. I believe it was a Pascal custom.

Aside from these rules, I'm not aware of any general CF/Carbon style guides.

You might try going even more general and picking up some books on C style. Compare and contrast between them; there is often no objectively-right answer.

One that I like is “Enough Rope to Shoot Yourself in the Foot”, by Allen Holub. It's witty and makes some good cases. Holub has a summary version on his website (just the rules themselves, without the detailed explanations); as far as I can tell, the full book is out of print.

Peter Hosey
+3  A: 

Core Foundation Design Concepts at the Mac Dev Center actually cleared up my question.

Dr. Watson