Cocoa的编码规范

Introduction to Coding Guidelines for Cocoa

https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CodingGuidelines/CodingGuidelines.html#//apple_ref/doc/uid/10000146-SW1

Developing a Cocoa framework, plug-in, or other executable with a public API requires some approaches and conventions that are different from those used in application development. The primary clients of your product are developers, and it is important that they are not mystified by your programmatic interface. This is where API naming conventions come in handy, for they help you to make your interfaces consistent and clear. There are also programming techniques that are special to—or of greater importance with—frameworks, such as versioning, binary compatibility, error-handling, and memory management. This topic includes information on both Cocoa naming conventions and recommended programming practices for frameworks.

Organization of This Document

The articles contained in this topic fall into two general types. The first and larger group presents naming conventions for programmatic interfaces. These are the same conventions (with some minor exceptions) that Apple uses for its own Cocoa frameworks. These articles on naming conventions include the following:

  • “Code Naming Basics”

  • “Naming Methods”

  • “Naming Functions”

  • “Naming Properties and Data Types”

  • “Acceptable Abbreviations and Acronyms”

The second group (currently with a membership of one) discusses aspects of framework programming:

  • “Tips and Techniques for Framework Developers”


Cocoa的编程规范介绍

开发一个Cocoa framework,插件,或者利用公共API编写的其他的可执行程序,需要一些approaches和一些不同于应用开发的规范。这些规范主要是用于产品开发者,这些的接口规范需要很清晰,以免他们会感到迷惑。这就是这篇文档想要做的事情,它能帮助你来让你的接口保持一致和清晰。也有许多编程技术对于框架的开发具有特殊性和重要性,比如版本管理,二进制兼容性,错误处理以及内存管理等。这篇文章包含了Cocoa命名规范和推荐框架编程实践两方面的内容。

这篇文章的组织结构

这篇文章包含了包含了两个普通类型的内容。第一部分是也是最大的篇幅来介绍编程接口的命名规范。苹果自己也在使用这些规范来编写Cocoa的框架。命名规范包含一下几篇文章:
     “ 代码命名基础”
     “函数命名”
     “方法命名”
      “属性和数据类型命名”
      “可接受的缩略词缩写”
第二部分会讨论框架编程部分
     “框架开发者的开发注意事项以及相关技术”

你可能感兴趣的:(Cocoa的编码规范)