博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
FBReaderJ 的编码风格
阅读量:6268 次
发布时间:2019-06-22

本文共 2561 字,大约阅读时间需要 8 分钟。

  hot3.png

  • 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
      • fields
      • constructors
      • 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 }}

转载于:https://my.oschina.net/sjr/blog/125889

你可能感兴趣的文章
java实现分页工具类(JDBC)
查看>>
欧几里德算法与扩展欧几里德算法
查看>>
Tinkoff Internship Warmup Round 2018 and Codeforces Round #475 (Div. 2)
查看>>
通过kafka提供的命令来查看offset消费情况
查看>>
oracle数据库从入门到精通之四
查看>>
自定义圆形图片控件
查看>>
sharepoint 2013 补丁升级步骤
查看>>
asp.net core 2.0 web api基于JWT自定义策略授权
查看>>
Skype for Business Server 2015-04-前端服务器-3-安装-管理工具
查看>>
第12章代码《跟老男孩学习Linux运维:Shell编程实战》
查看>>
我们为什么从Python转到go?
查看>>
5.Azure负载均衡(上)
查看>>
轻松精通awk数组企业问题案例
查看>>
26.Azure备份服务器(下)
查看>>
从“网上说的能信么”说开去---学习的思考
查看>>
DHCP 日志分析
查看>>
.NET Micro Framework动态调用C/C++底层代码(原理篇)
查看>>
Windows Server 2012正式版RDS系列⒃
查看>>
Shell脚本之awk篇
查看>>
微软发布Azure Stack硬件需求
查看>>