开发者

Apple Carbon/CoreFoundation style guide?

Cocoa is well-documented开发者_如何学C 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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜