Objective-C基础8 :命名约定(naming conventions)

由于OC里面没有命令空间这种利器来避免名字空间,所以得特别注意名字污染,一般的命令约定由如下几条:

1.类、类别、协议的命名在整个工程里面必须保持全局唯一。以前缀开始并且以大写字母开头,比如XPZMyPerson;

2.类方法和属性的命名以小写字母开头,多个单词组成的方法和属性名称遵循camel case,比如myName。类方法和属性的命名只需要在类以及类的继承链里面保存唯一即可。需要注意的是类别方法需要全局唯一,加前缀命令。

3.实例变量的set和get方法命名约定,set方法命名为set+变量名称,get方法直接为变量名称。比如setMyName,MyName。

4.类的工厂方法去掉前缀开始。比如XPZMyPerson的类厂方法命名为myPersonwitName。

时间: 2024-08-02 12:29:11

Objective-C基础8 :命名约定(naming conventions)的相关文章

Spring mvc 4系列教程(二)——依赖管理(Dependency Management)和命名规范(Naming Conventions)

依赖管理(Dependency Management)和命名规范(Naming Conventions) 依赖管理和依赖注入(dependency injection)是有区别的.为了将Spring的优秀特性(如依赖注入)带到你的应用中,需要在编译时或运行时部署所需要的库(jar包).这些依赖不是虚拟的构件,而是文件系统上的物理资源.依赖管理的过程涉及到定位这些资源.存储资源.加入classpath.依赖可以是直接的(例如Spring运行时),也可以是间接的(例如commons-dbcp).间接

JavaScript Patterns 2.10 Naming Conventions

1. Capitalizing Constructors var adam = new Person(); 2. Separating Words camel case - type the words in lowercase, only capitalizing the first letter in each word. upper camel case, as in  MyConstructor(), lower  camel  case,  as  in  myFunction(),

Naming Conventions for .NET / C# Projects

http://www.akadia.com/services/naming_conventions.html Naming Conventions for .NET / C# Projects Martin Zahn, Akadia AG, 20.03.2003 The original of this document was developed by the Microsoft special interest group. We made some addons. This documen

C# Coding & Naming Conventions

Reference document https://msdn.microsoft.com/en-us/library/ff926074.aspx https://msdn.microsoft.com/en-us/library/ms229045(v=vs.110).aspx Coding Conventions Layout Conventions Use the default Code Editor settings (smart indenting, four-character ind

Objective - C基础: 第六天 - 2.ARC转换以及第三方框架的管理

在我们之前的项目中, 或多或少都会有手动引用计数的存在, 看到apple出了自动引用计数, 再看看自己的项目, 就有一种砸电脑的冲动, 别着急~~其实apple很为我们开发者着想, 旧项目一样可以转成ARC, 废话少说, 直接上图: 后面的操作不需要我讲了吧? 傻瓜式的操作, 一直下一步, 直到完成为止, 这样子你的项目就会焕然一新~~~全世界都舒服晒(粤语)~~~ 但问题来了, 有一些第三方框架不支持ARC, 那肿么办?? 别着急, apple为开发者考虑的很多, 一样有办法可以解决~~~继续

【转】Python——编码规范

来自于 啄木鸟社区 Python Coding Rule --- hoxide 初译 dreamingk 校对发布 040724 --- xyb 重新排版 040915 --- ZoomQuiet MoinMoin 美化 050610 用Python进行开发时的编码风格约定 原文:PEP 008 <Style Guide for Python Code> 下载(中文pdf): PythonCodingRule.pdf 进一步的: Google Python Style Guide Python

SWIG 3 中文手册——5. SWIG 基础知识

目录 5 SWIG 基础知识 5.1 运行 SWIG 5.1.1 输入格式 5.1.2 SWIG 输出 5.1.3 注释 5.1.4 C 预处理器 5.1.5 SWIG 命令 5.1.6 解析限制 5.2 包装简单的 C 声明 5.2.1 处理基本类型 5.2.2 全局变量 5.2.3 常量 5.2.4 一点关于 const 的文字 5.2.5 char * 的注意事项 5.3 指针与复杂对象 5.3.1 简单指针 5.3.2 运行时指针类型检查 5.3.3 派生类型.结构体和类 5.3.4 未

Error解决:Property&#39;s synthesized getter follows Cocoa naming convention for returning &#39;owned&#39;

在项目中定义了以new开头的textField,结果报错: 先看我的源码: #import <UIKit/UIKit.h> @interface ResetPasswordViewController : UIViewController @property (weak, nonatomic) IBOutlet UITextField *phoneTextField; @property (weak, nonatomic) IBOutlet UITextField *oldPasswordTe

官方的objective - c风格指南。

The official raywenderlich.com Objective-C style guide. This style guide outlines the coding conventions for raywenderlich.com. Introduction The reason we made this style guide was so that we could keep the code in our books, tutorials, and starter k