已阅读5页,还剩41页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Eric Huang s Creative Studio Flex SDK 编码规范及最佳实践编码规范及最佳实践 资料共享 资料共享 注意 本文档目前还不完整且有些部分以TBD 待讨论 标记 但这对于起步已经足够了 引言引言 这篇文档拟定了用 AS3 编写开源 Flex 框架组件的编码规范 遵照这些规范可以使得源代码看起来组织良好 风 格一致并且更加专业 其中有些规范是很任意的 因为并非总存在一种 最好方式 来编码 然而 为了照顾一致性 的要求 所有付诸 Flex SDK 的项目都将遵循这些编码规范 目录目录 命名命名 缩写词 缩略语 单词定界 类型指定名 包名 文件名 命名空间名 接口名 类名 事件名 样式名 字符串属性枚举值 常量名 属性 变量和 getter setter 名 存储变量名 方法名 事件处理方法名 参数名 资源包名 资源键名 杂项名 语言用法语言用法 编译选项 基于属性的 APIs 类型定义 Eric Huang s Creative Studio Literals Expressions Statements Declarations 文件组织文件组织 Copyright notice package statement import statements use namespace statement Class metadata Class declaration include statement for Version as Implementation notes Class initialization Class constants Class mix ins Class resources Class variables Class properties Class methods Constructor Variables Overridden properties Properties Overridden methods Methods Overridden event handlers Event handlers Out of package helper classes 格式化格式化 Line width Indentation Section separators Separation of declarations Metadata Array indexing Commas Array literals Object literals Function literals Type declarations Eric Huang s Creative Studio Operators and assignments Statements Constant and variable declarations Function declarations Function calls if statements for statements switch statements class and interface declarations ASDoc 文档文档 Property comments 命名命名 编码时采用合适的命名既便于使用且理解起来也更为容易 所以你得在选择好的命名方式二多费心力 特别是针对 公共 API 提供出来的时候 我们的命名规范绝大部分和 ECMAScript 和 Flash Player 9 是一致的 缩写词缩写词 作为通用规则而避免使用 例如calculateOptimalValue 比calcOptVal 的命名方式更优 表意明确比为了少敲几下代码而采用缩写更为重要 如果你不使用缩写 开发人员就不用非得记住你是否采用了 单词简写 如把 qualified 简写成 qual 或 qlfd 不过 我们已经标准化了一些缩写词 acc 代表 accessibility 比如 ButtonAccImpl auto 代表 automatic 比如autoLayout eval 代表 evaluate 比如EvalBindingResponder impl 代表 implementation 比如ButtonAccImpl info 代表 information 比如GridRowInfo num 代表 number of 比如numChildren min 代表 minimum 比如minWidth Eric Huang s Creative Studio max 代表 maximum 比如maxHeight nav 代表 navigation 比如NavBar regexp 代表 regular expression 比如RegExpValidator util 代表 utility 比如StringUtil 上述列表可能没有包含目前使用的所有缩写词 如果你用到了上面没有列举出来的缩写词 请搜索源代码看是否已 经有相应的缩写词使用了 如果没发现 再考虑一下如果缩写是否合适 有时我们 故意 采用的缩写词不一致 例如 我们在很多时候都会拼写 horizontal 和 vertical 像 horizontalScrollPolicy 和 verticalScrollPolicy 但是我们在常规容器类名 HBox 和 VBox 中却将它们缩写成了 H V 缩略语缩略语 在 Flex 中有各种缩略语 像 AIR CSS HLOC IME MX MXML RPC RSL SWF UI UID URL WSDL 和 XML 之类 一条缩略语要么全部大写要么全部小写 e g SWF 或 swf 但不会是 Swf 使用全部小写的缩略语形式是 当使用本身作为标识符或者作为某个标识符的开头 以及标识符需用小写字母开头时 可以参照一下关于标识 符到底以大写还是小写开头的规则一条缩略语要么全部大写要么全部小写 e g SWF 或 swf 但不会是 Swf 使用全部小写的缩略语形式是使用本身作为标识符或者作为某个标识符的开头 标识符必须以小写字母 开头 可以参照一下关于标识符到底以大写还是小写开头的规则 和缩略语有关的标识符有CSSStyleDeclaration IUID uid IIME和imeMode 单词定限单词定限 当标识符包含多个单词时 我们采用两种方式表明单词界限 单词首字母大写 比如 LayoutManager measuredWidth 和下划线连接 比如object proxy 具体采用哪种方式请参照一下规则 有时候由于不清楚一个单词组合是不是已经成为一个独立的新词了 所以这种情况下会出现不一致的情况 deopdown popUp popUp 即使出现两个缩略语相邻时也要遵循首字母大小写的规则 loadCSSURL 就是一个很符合这种情形的例子 实际上很少使用 但是尽量避免使用那样的名字 类型指定名类型指定名 Eric Huang s Creative Studio 如果你想要在命名中纳入类型标示 将类型作为最后一个 词 If you want to incorporate the type into the name make it the last word 不要使用 ACTIONSCRIPT 1 的类型连接后缀如 mc 表明类型 例如 命名一个 border shape 可以是 border borderSkin 或 borderShape 但不是 border mc 常常 对象最简单的名字就是它本身的类型 当然要采取和类型名不同的大小写方式 var button Button new Button 包名包名 以小写字母开头然后接下来的单词采用首字母大写 controls listClasses 包名总是名词或动名词 动词 ing 的名词形式 而非动词 连词或副词 实现了许多相似东西的包的包名要采用该类事物的复数形式 charts collections containers controls effects events formatters managers preloaders resources skins states styles utils validators 对于实现了某种概念的包一般用动名词的形式 binding logging messaging printing 否则 它们通常只是 概念名词 accessibility core graphics rpc 一个包含支持 FooBar 组件的类应当命名为fooBarClasses 文件名文件名 对于重要的 APIs 文件名必须要和公共 API 内部的名字一致 但是包含文件必须要遵从这个规则 对于含一个大写字母的元数据 Style 包含文件的文件名 后续单词采用首字母大写且将最后单词 写为 sytles BorderStyles as ModalTransparencyStyles as 以全部小写字母并且下划线进行单词连接的形式来命名个人资产文件 icon align left png 命名空间名命名空间名 已全部小写字母并且消化腺进行单词连接的形式命名 mx internal object proxy 接口名接口名 以 I 开头并且后续单词使用首字母大写的形式 IList IFocusManager IUID Eric Huang s Creative Studio 类名类名 大写字母开头后续单词首字母大写 Button FocusManager UIComponent Event子类命名 FooBarEvent Error子类命名FooBarError Name the EffectInstance subclass associated with effect FooBar FooBarInstance Formatter子类命名FooBarFormatter Validator子类命名FooBarValidator 外观类命名 FooBarBackground FooBarBorder FooBarSkin FooBarIcon FooBarIndicator FooBarSeparator FooBarCursor等 工具类命名 FooBarUtil 不是 FooBarUtils 包名复数但类名要用单数 常用基类命名方式 FooBarBase ComboBase DateBase DataGridBase ListBase 事件名事件名 小写字母开头并且后续单词首字母大写 move creationComplete 样式名样式名 小写字母开头并且后续单词首字母大写 color fontSize 字符串属性枚举值字符串属性枚举值 小写字母开头并且后续单词首字母大写 auto filesOnly 常量名常量名 Eric Huang s Creative Studio 全部大写且单词采用下划线连接 OFF DEFAULT WIDTH 常量值如果是 string 类型的 那么它的 value 要和常量名保持一致 public static const FOO BAR String fooBar 属性属性 变量和变量和 getter setter 名名 小写字母开头并且后续单词首字母大写 i width numChildren 使用i作为 for 循环的外层循环索引值 n 作为其上限值 使用j作为 for 循环的内层循环索引值 m 作为其 上限值 for var i int 0 i n i for var j int 0 j m j 使用 p 表示 property 作为for in 循环变量 for var p String in o 如果一个类重写了一个 getter setter 但还想继续公开基类的 getter setter 它就得单独用一个属性 属性吗 为基类中属性名前加一个前缀 这个 getter setter 要以 final 标记且不做任何额外的 coding 除了调用 super getter setter mx internal final function get numChildren int return super numChildren 存储变量名存储变量名 替 getter setter foo 命名一个存储变量名 foo 方法名方法名 小写字母开头并且后续单词首字母大写 measure updateDisplayList Eric Huang s Creative Studio 方法名应当总是动词 不带参数的方法不应当采取getFooBar 或 setFooBar 命名形式 而应设计成 getter setter 不 过 如果getFooBar 是一个需要大量计算的缓慢方法 应当将其命名为findFooBar calculateFooBar determineFooBar 等 而不是一个 getter 如果一个类重写了一个方法 但还想继续公开基类的方法 它就得单独实现一个方法 方法名为基类中方法名前 加一个前缀 这个 method 要以 final 标记且不做任何额外的 coding 除了调用 supermethod mx internal final function addChild child DisplayObject DisplayObject return super addChild child 事件处理方法名事件处理方法名 事件处理程序名应当在事件类型后面连接一个 Handler mouseDownHandler 如果处理程序是服务于派发给子控件的事件 i e not this 在处理程序名前面加一个子控件名前缀然后以 下划线后处理程序名组合 textInput focusInHandler 参数名参数名 对任何 setter 的参数使用value 作为参数名 这样做 public function set label value String void 而不是 public function set label lab String void 或者这样做 public function set label labelValue String void 或者这样做 public function set label val String void Eric Huang s Creative Studio 使用 event 而非 e evt or eventObj 作为每个事件处理程序的参数 protected function mouseDownHandler event Event void 资源包名资源包名 如果一个资源包名包含特定包的资源 应该以相同的名字命名这个资源包 controls formatters validators 资源键名资源键名 小写字母开头且后续单词首字母大写 pm dayNamesShort 杂项名杂项名 避免 object 因为它意义模糊 一个 item 是一个 data item 而不是一个 DisplayObject 一个 renderer 是一个显示 data item 的 DisplayObject 一个 type 一个 AS3 类型 否则使用 kind 语言使用语言使用 这部分我们将讨论如何使用 AS3 的语言构造 尤其当同一事物存在多种表述手段时 编译选项编译选项 采用 strict and show actionscript warnings 编译选项进行编译 在 flex config xml 文件中会有一些缺省值 基于属性的基于属性的 APIs 建议使用基于属性的 APIs 而不是基于方法的 APIs 因为这些更加适合声明式的 MXML 编程 类型定义类型定义 为每个常量 变量 函数参数以及函数返回值甚至如果简单地使用 表明 无类型 这样做 Eric Huang s Creative Studio var value 而不是这样 var value 使用合适的最紧致的类型 例如 循环变量索引应当是 int 型 不是 Number 型 当然更不会是 Object 或 另一个例子 mouseDownHandler应当声明一个参数 event MouseEvent 而不是 event Event 整型数使用int 即使它不是负数 使用uint作为 RGB 颜色值 位掩码和其他非数字值 使用 仅在该值没有定义的情况下 你应当通常使用 Object 而不是 You should generally use Object rather than 具有 null 代表 对象不存在 值 如果你声明 Array 类型的变量 你得添加一个 of ElementType 形式的注释紧接着 Array 表明该数组元素 的类型 未来版本的语言可能会支持这种类型化的数组 这样做 var a Array of String 而不是这样 var a Array 这样做 function f a Array of Number Array of Object 而不是这样 function f a Array Array 文本文本 undefinedundefined Eric Huang s Creative Studio 避免使用如果可能的话 仅仅是在编译时变量的类型是 It is only necessary when dealing with values whose compile time is type is and you should be using sparingly as well intint uintuint 不要在 integar 中使用小数点 这样做 2 而不是这样 2 十六进制数使用一个小写字母x和大写字母 A Z 这样做 0 xFEDCBA 而不是这样 0Xfedcba RGB 颜色值总是采用这种 6 位十六进制数表示 这样做 private const BLACK uint 0 x000000 而不是这样 private const BLACK uint 0 NumberNumber 如果一个 Number 值可以是小数 则一般要加上一个小数点并补上 0 即使实际值是个整数值 这样做 alphaFrom 0 0 alphaTo 1 0 而不是这样 alphaFrom 0 Eric Huang s Creative Studio alphaTo 1 不过 对于像素坐标即使是小数形式 也最好使用整数值表示它 这样做 var xOffset Number 3 而不是这样 var xOffset Number 3 0 指数表示法表示数字时使用 e 而不是 E 这样做 1 0e12 而不是这样 1 0E12 使用值NaN 作为非Number类型的缺省值值 StringString 使用引号标记 双引号 而不是撇号 单引号 限定字符串 即使那个字符串包含一个引号作为其内部某个字符 这样做 What s up Big Boy 而不是这样 What s up Big Boy 使用 u not U 作为 Unicode 转义字符序列 ArrayArray 使用数组文本而非new Array 这样做 Eric Huang s Creative Studio 而不是这样 new Array 这样 1 2 3 而不是 new Array 1 2 3 使用 Array 构造函数仅仅是作为预留数组大小时 比如new Array 3 意为 undefined undefined undefined not 3 ObjectObject 使用 Object 文本而非new Object 这样做s 而不是这样 new Object 这样做 o a 1 b 2 c 3 而不是这样 o new Object o a 1 o b 2 o c 3 或这样 o o a 1 o b 2 o c 3 Eric Huang s Creative Studio FunctionFunction 避免使用函数文本定义匿名函数 使用一个类方法或包函数替代 如果你必须使用函数文本 声明一个返回类型 在函数体内用一个分号终止最后一条语句 这样做s function i int void doIt i 1 doIt i 1 而不是这样 function i int doIt i 1 doIt i 1 RegExpRegExp 使用字面值而不是一个字符串构造的 RegExp 实例 这样做 var pattern RegExp d g 而不是这样 var pattern RegExp new RegExp d g XMLXML and XMLListXMLList 使用字面值而不是 XML 构造函数形式 U 这样 var node XML 而不是这样 var node XML new XML 对于 XML 属性值使用双引号括起来 这样做 var node XML 而不是这样 var node XML ClassClass Eric Huang s Creative Studio 仅当存在导入类型歧义时才采用类名的全路径形式声明一个类 这样做 import mx controls Button var b Button new Button 而不是这样 import mx controls Button var b Button new mx controls Button 但下面这种情况下使用全限定名才是合适的 import mx controls Button import my controls Button var b Button new mx controls Button 表达式表达式 括号括号 对于常用操作符如 such as 而不是这样 var e Number a b c d 这样做 var e Boolean a 而不是这样 var e Boolean a 各个操作符的优先级很难记住 所以我们可以运用括号就会十分有用了 强制转换强制转换 不要将 Boolean 值和 true 和 false 比较 因为它的值必然是其中之一 Eric Huang s Creative Studio 这样做 if flag 而不是这样 if flag true 这样做 var flag Boolean a 而不是这样 var flag Boolean a 很显然强制转换 Number String XML XMLList Array Object 或者 为 Boolean 转换错误会有多个值我们 很难记住 类型类型你能记起一下哪个是强制转换失败时的值吗你能记起一下哪个是强制转换失败时的值吗 Number0 NaN Stringnull XML XMLListnull Arraynull Objectnull 0 NaN false undefined null 0 NaN false 这样做 if s null i n i 而不是这样 for var i int 0 i n i 条件运算符条件运算符 Eric Huang s Creative Studio 用条件运算符代替 if else 形式 特别是想要检验是否有 null 值时 这样做 return item item label null 而不是这样 if item return null return item label 主要最好不要将多个条件运算符代替复杂的 if else 逻辑结构 这样做 if a b return 1 return 0 而不是这样 return a b 1 0 newnew 运算符运算符 使用括号紧随类型引用 即使这个类的构造函数不带任何参数 这样做 var b Button new Button 而不是这样 var b Button new Button 语句语句 每条语句后面都要接一个分号 虽然在 AS 3 中并没有这个强制要求 这样做 a 1 b 2 c 3 Eric Huang s Creative Studio 而不是这样 a 1 b 2 c 3 includeinclude语句语句 使用 include 而不是 include 也像其他语句一样后面加个分号结束 这样做 include core ComponentVersion as 而不是这样做 include core ComponentVersion as 使用相对路径而不是绝对路径 ImportImport语句语句 导入特定类 接口和其他包级的函数而不是 通配符 这样做 import mx controls Button import flash utils getTimer 而不是这样 import mx core useuse namespacenamespace语句语句 避免使用它们 使用 语法提到 syntax instead on each reference to something in a non open namespace 这样做 import mx core mx internal Later in some method mx internal doSomething 而不是这样 Eric Huang s Creative Studio import mx core mx internal use namespace mx internal Later in some method doSomething ifif 语句语句 如果 if else 的不同分支涉及到单条语句 不需要大括号包含它 这样做 if flag doThing1 而不是这样 if flag doThing1 这样做 if flag doThing1 else doThing2 而不是这样 if flag doThing1 else doThing2 但是如果有多条语句时可以将大括号包含起来 这样做 Eric Huang s Creative Studio if flag doThing1 else doThing2 doThing3 而不是这样 if flag doThing1 else doThing2 doThing3 如果测试多个 error 检查 可以使用一系列 if 语句段测试错误并提前返回 正确的执行流放到最后返回 true 不要使用嵌套的 if 语句来判断 这样会导致执行流整个块中都有 这样做 if condition1 return false if condition2 return false if condition2 return false return true 而不是这样 if condition1 Eric Huang s Creative Studio if condition2 if condition3 return true return false forfor 语句语句 即使 for 语句块只有一条语句也要用大括号括起来 这样做 for var i int 0 i 3 i doSomething i 而不是这样 for var i int 0 i 3 i doSomething i 对于上限我们用一个单独的变量来存储 这样不会使得每次判断的时候都要重复计算 这样做 var n int a length for var i int 0 i n i 而不是这样 for var i int 0 i a length i Eric Huang s Creative Studio 在循环括号里面声明循环变量 除非其他地方要用到这个变量 这样做 for var i int 0 i 3 i 而不是这样 var i int for i 0 i 3 i whilewhile 语句语句 即使只有一条语句也要用括号括起来 这样做 while i n doSomething i 而不是这样 while i n doSomething i dodo 语句语句 即使一条语句也要括起来 t 这样做 do doSomething i while i n Eric Huang s Creative Studio 而不是这样 do doSomething i while i n switchswitch 语句语句 将每一个 case 子句作为一个块 包括 default 子句 将 break 和 return 语句置于块中 将 default 子句也当 做 case 子句 避免出现 case 穿透问题 这样做 switch n case 0 foo break case 1 bar return case 2 baz return default blech break Eric Huang s Creative Studio 而不是这样 switch n case 0 foo break case 1 bar break case 2 baz return break default blech returnreturn 语句语句 不需要将返回值用括号括起来 这样做 return n 1 而不是这样做 return n 1 从方法体中部返回也是可以的 声明声明 不要在同一行声明多个变量或常量 这样做 Eric Huang s Creative Studio var a int 1 var b int 2 而不是这样 var a int 1 b int 2 overrideoverride关键字关键字 如果存在重载的情况 请将这个关键字放在第一位 在访问限定符前面 这样做 override protected method measure void 而不是这样 protected override method measure void 访问限定符访问限定符 在需要访问限定的地方放置上访问限定符 不要不写 虽然这样表示默认的访问限定 internal 在构造 public 或者 protected 的 API 时 仔细想想是否需要这样做 Public 和 protected 的 APIs 必须进行 文档化 在正式被终止之前需要支持好几个发布版本 StaticStatic关键字关键字 如果存在 请将这个关键字放在访问限定符之后 这样做 public static const MOVE String move 而不是这样 static public const MOVE String move finalfinal关键字关键字 如果存在 将它放在访问限定符后面 这样做 public final class BoxDirection 而不是这样 final public class BoxDirection 将所有 枚举类 声明为 final 型的 Eric Huang s Creative Studio 也常常将 基本 属性和方法 以 开头 为 final 类型 常量常量 所有的常量应该是 static 的 不应将一个实例声明为常量 应该所有的哦实例将使用同样的值 这样做 public static const ALL String all 而不是这样 public const ALL String all 变量变量 如果变量需要初始化为一个值 而不是使用默认值 在声明变量的时候就初始化而不用等到构造函数里面再初 始化 这样做 private var counter int 1 而不是这样做 private var counter int public function MyClass super counter 1 局部变量局部变量 内部变量在使用的时候才进行声明 而不要都放在函数开始时 这样做 private function f i int j int int var a int g i 1 g i 1 var b int g a 1 g a 1 var c int g b 1 g b 1 Eric Huang s Creative Studio return a b c a b c 而不是这样做 private function f i int j int int var a int var b int var c int a g i 1 g i 1 b g a 1 g a 1 c g b 1 g b 1 return a b c a b c Declare local variables only one per function ActionScript 3 doesn t have block scoped locals Do this var a int if flag a 1 else a 2 Not this if flag var a int 1 Eric Huang s Creative Studio else var a int 2 And this var i int for i 0 i n i for i 0 i n i Not this for var i int 0 i n i for var i int 0 i n i 类类 如果一个类简单地继承自 Object 不用显示写出 extends Object 子句 The only bare statements in a class should be calls to static class initialization methods such as loadResources 构造函数构造函数 Eric Huang s Creative Studio 如果一个类有实例变量 要书写一个构造函数 显示使用 super 即使它没做任何事情 如果构造函数参数对应于实例变量 参数名可以使用与实例名同样的名字 这样做 public function MyClass foo int bar int this foo foo this bar bar 而不是这样做 public function MyClass fooVal int barVal int foo fooVal bar barVal 不要在构造函数中设置类实例变量 在实例声明时就初始化 不过 如果你需要重置从父类实例中继承的变量 值 可以在构造函数中做 接口接口 TBD 命名空间命名空间 TBD 实现属性实现属性 TBD 元数据元数据 TBD 包包 在包语句中中的公共 API 常常是一个类 有时是一个明明空间或函数 帮助类 空语句 Eric Huang s Creative Studio 文件组织文件组织 这部分主要阐释 Flex 框架文件应当如何组织 版权声明版权声明 在框架文件下每一个 as 文件头部都应包括一个版权声明 下面给出 2008 版开源版本的格式 ADOBE SYSTEMS INCORPORATED Copyright 2008 Adobe Systems Incorporated All Rights Reserved NOTICE Adobe permits you to use modify and distribute this file in accordance with the terms of the license agreement accompanying it 注意每一行最多包含 80 个字符 包语句包语句 TBD 导入语句导入语句 TBD 使用命名空间语句使用命名空间语句 TBD Class 元数据元数据 将类中元数据按 Events Styles Effects Excluded IPIs 和其它元数据顺序分成几个部分 在每个部分前面加一个小的说明头 注意每个说明头是 40 个字符宽度在 和其后 区块名之间有两个空格 每个区块将元数据名 按字母表顺序排列出来 在其他元数据区块 将元数据标签名按字母表顺序列出 Eric Huang s Creative Studio Events ASDoc comment Event ASDoc comment Event Styles ASDoc comment Style ASDoc comment Style Effects ASDoc comment Effect Eric Huang s Creative Studio ASDoc comment Effect Excluded APIs Exclude name horizontalAlign kind style Exclude name verticalAlign kind style Other metadata DefaultBindingProperty source text destination text IconFile Text png Class 声明声明 TBD Version as include 语句语句 每个类应当使用相对路径包含 core Version as 这个文件包含static const VERSION String 声 明 include core Version as 实现注释实现注释 TBD 类初始化类初始化 TBD 类常量类常量 将静态常量声明置于此 Eric Huang s Creative Studio ActionScript 3 不允许常量具有 Array or Object 类型 声明那种常量使用 static var 而不是 static const 将它们放在这个部分因为概念上它们也属于常量 类最小化类最小化 将任何 Function 类型声明为静态变量而不是声明为方法减小类大小 类资源类资源 TBD 类变量类变量 TBD 类属性类属性 声明静态 getters 和 setters 然后将它们按字母表顺序排列 使用 Declare static getters and setters here Order them alphabetically by property name Use a minor separator with the property name for each one Put the getter before the setter 类方法类方法 放置静态方法声明 构造函数构造函数 TBD 变量变量 TBD 重载属性重载属性 Put overrides of non static getters and setters here Order them alphabetically by property name Use a minor separator with the property name for each one Put the getter before the setter 属性属性 Put new non static getters and setters here Order them alphabetically by property name Use a minor separator with the property name for each one Put the getter before the setter 重载方法重载方法 Put overrides of non static functions here Eric Huang s Creative Studio 方法方法 Put new non static functions here 重载事件处理函数重载事件处理函数 Put overrides of event handlers here 事件处理函数函数事件处理函数函数 Put new event handlers here 包外帮助类包外帮助类 TBD 格式化格式化 This section covers how a Flex framework class should be formatted 行宽度行宽度 Wrap code to 80 character lines This has the following advantages Developers with smaller screens don t have to scroll horizontally to read long lines A comparison utility can display two versions of a file side by side The font size can be increased for projection before a group without requiring scrolling The source code can be printed without clipping or wrapping 缩进缩进 Use 4 space indentation Configure your text editor to insert spaces rather than tabs This allows another program that uses a different indentation setting such as Notepad with its 8 character indents to display the code without disfiguring it Section separators The major section separators inside a class look like this Overridden methods Eric Huang s Creative Studio They extend from column 4 through column 80 The text is indented to column 8 The minor section separators inside a class such as between properties look like this visible They extend from column 4 through column 40 The text is indented to column 8 Put a single blank line above and below the separators Separation of declarations Use a single blank line as a vertical separator between constant variable or function declarations private Holds something var a Number private var b Number Metadata TBD Do this Inspectable a 1 b 2 Not this Inspectable a 1 b 2 Array indexing Don t put any spaces before or
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 出资担保协议书模板
- 土地丈量务工协议书
- PAS协议书是什么
- 家居布艺鞋袋新品创新创业项目商业计划书
- 复古与现代女鞋融合创新创业项目商业计划书
- 建筑石材尺寸创新创业项目商业计划书
- 声纳装备创新创业项目商业计划书
- 指纹校园一卡通系统创新创业项目商业计划书
- (2025)职工违规违纪廉洁教育试题(附答案)
- 2024年贵州黔南州村干部专项招聘乡镇事业单位真题
- 足球脚背内侧踢球
- 《新污染物治理技术》-课件 第1章 新污染物简介
- 创新联合体建设合同
- 产力异常的课件
- 大学班级干部培训课件
- 炸药库保安员安全培训课件
- 字节运营工作总结
- 医院运营管理培训
- 激光3D打印人形机器人关节结构拓扑优化研究
- 人教版(2024)二年级上册《身体上的尺子》单元测试卷(含解析)
- 叉车司机三级试题+答案
评论
0/150
提交评论