注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

技术乐土

这是一片技术的乐土

 
 
 

日志

 
 

FBReader J coding style  

2012-02-28 15:35:55|  分类: android |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
https://github.com/geometer/FBReaderJ/wiki/FBReaderJ-coding-style-guide
  • Naming convention

    • All the classes, interfaces, methods and variables should be named in CamelCaseStyle.
    • All the constant (i.e. public static final fields) names should be written in upper case, with '_' as a word separator.
    • We prefer to use complete English words in names: doSomething() is much better than doSmth() or sdelatNechto().
    • Class and interface names should be started from an upper-case character, methods, fields and variables should be started from a lower-case character.
    • All the (non-static) field names should have prefix 'my'. (We omit this prefix and start a field name with an upper-case character for public final fields; see below.)
    • All the static (non-constant) field names have prefix 'our'.
  • Formatting

    • We use tabs for indenting. In our editors a tab is visible as 4 spaces.
    • We place all the opening brackets ( { ) on the same line where the corresponding control structure is located.
  • Other rules

    • We prefer to make class fields final if it is possible.
    • For final fields, we prefer to make the field public instead of creating a getter. For such fields we do not use prefix 'my'; we start such name with an upper-case character.
    • If something in an existing code is not implemented at this moment, we insert a TODO-marked comment.
    • By historical reasons we do not use enums; please use a set of integer constants instead.
    • We prefer to write class members in the following order:
      • constants
      • static fields
      • static methods
      • constructors
      • fields
      • methods
  • A sample

    class Book {
    public static final int BOOK_FORMAT_EPUB = 0;
    public static final int BOOK_FORMAT_FB2 = 1;

    private static ourCounter = 0;

    public static getCounter() {
    return ourCounter;
    }

    public final String Title;
    private int myCurrentPageNumber;

    public Book(String title, int currentPageNumber) {
    ++ourCounter;
    Title = title;
    myCurrentPageNumber = currentPageNumber;
    }

    public Book(String title) {
    this(title, 0);
    }

    public int getCurrentPageNumber() {
    return myCurrentPageNumber;
    }

    public void gotoNextPage() {
    // TODO: check if we are already at the last page; do nothing in such case
    ++myCurrentPageNumber;
    // TODO: update the view
    }

    public void gotoPreviousPage() {
    if (myCurrentPageNumber == 0) {
    return;
    }
    // TODO: implement
    }
    }
  评论这张
 
阅读(105)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017