Flex 规范

来源:互联网 发布:购买备案域名可以用吗? 编辑:程序博客网 时间:2024/05/22 15:12

原文地址:

http://opensource.adobe.com/wiki/display/flexsdk/Coding+Conventions

1. 尽量避免使用缩写,名字长点没关系,最重要的是要让人看懂。当然在项目中约定的缩写是可以使用的,例如以下是flex sdk的一些缩写约定。

 Avoid them as a general rule. For example, calculateOptimalValue() is a better method name than calcOptVal().

And if you don't abbreviate, developers won't have to remember whether you shortened a word like “qualified” to “qual” or “qlfd”.

However, we have standardized on a few abbreviations:

acc for accessibility, as in ButtonAccImpl
auto for automatic, as in autoLayout
auto for automatic, as in autoLayout
eval for evaluate, as in EvalBindingResponder
impl for implementation, as in ButtonAccImpl
info for information, as in GridRowInfo
num for number of, as in numChildren
min for minimum, as in minWidth
max for maximum, as in maxHeight
nav for navigation, as in NavBar
regexp for regular expression, as in RegExpValidator
util for utility, as in StringUtil

 

 

2. 对于只取首字母的缩写词,例如HTMLSWF,要么都大写,要么都小写 never Html or Swf

 

Various acronyms are common in Flex, such as AIR, CSS, HLOC, IME, MX, MXML, RPC, RSL, SWF, UI, UID, URL, WSDL, and XML.

An acronym is always all-uppercase or all-lowercase (e.g., SWF or swf, but never Swf).

Examples of identifiers with acronyms are CSSStyleDeclaration, IUID, uid, IIME, and imeMode.

 

 

3. 对于指定了类型的名字,例如 一个具有border Shape应该命名为 borderShape。再如,一个会shine button,因该命名为 shineButton

 

 

4. Package Name,在flex项目里,表现为目录名,必须使用小写字母,而且只能使用名词或动名词。

 

Start them with a lowercase letter and use intercaps for subsequent words: controls, listClasses.

Package names should always be nouns or gerunds (the -ing noun form of a verb), not verbs, adjectives, or adverbs.

 

 

5. 文件名的命名:对于一些很重要的API来说, 文件名必须跟API的名字一致。include files 可不必。一般文件名要以大写字母开头,波浪写法。而一些资源文件则采用下划线方式: icon_align_left.png

6.接口的命名必须以I作为开头

7. 类的命名: 第一个字母必须是大写,并采用波浪写法。以下是一些基于FLEX SDK的一些子类的命名方法,以供参考。

   一个原则: 修饰部分 + 名词。 修饰部分可以是动词、形容词或者是名词,可以是一个单词,也可以是多个,只要能够表达清楚就可以了。最后一个必须是名词。

原创粉丝点击