Apple Carbon/CoreFoundation 风格指南?
Cocoa 有详细的文档,并且有很多关于以良好形式编写 Cocoa 代码的信息。我正在编写一些与硬件密切配合的代码,需要我经常使用 CoreFoundation 和 Carbon API。是否有任何类型的“风格”指南可以帮助您理解 Apple 的 Carbon 和 CoreFoundation 等库? Apple 的示例代码中充斥着以下内容:
- kSomeValue
- CFMightDoSomethingUseful
我可以推断出 CF 表示 CoreFoundation,k 可能表示常量或枚举类型,但我想验证这一点并了解有关其他语法样式的更多信息。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Mac 开发中心的核心基础设计概念实际上已经清除提出我的问题。
Core Foundation Design Concepts at the Mac Dev Center actually cleared up my question.
具体来说,它是Core Foundation框架中函数、类型和常量的前缀。
是的。这可以追溯到 Toolbox 时代,甚至在 Core Foundation 存在之前。我相信这是帕斯卡的习俗。
除了这些规则之外,我不知道任何通用的 CF/Carbon 风格指南。
您可以尝试更笼统地学习一些关于 C 风格的书籍。它们之间的比较和对比;通常没有客观正确的答案。
我喜欢的一本是艾伦·霍鲁布(Allen Holub)所著的《足够的绳子搬起石头砸自己的脚》。它很机智,并提出了一些很好的案例。 Holub 在他的网站上有摘要版本(只是规则本身,没有详细解释);据我所知,整本书已经绝版了。
Specifically, it's the prefix for functions, types, and constants in the Core Foundation framework.
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.