编辑
This is the code styles applied to my projects and work.
本文访问次数:0
  1. 1. General code style
    1. 1.1. Clarity
  2. 2. Language specific code styles
    1. 2.1. PHP
    2. 2.2. Objective-C
    3. 2.3. Java
    4. 2.4. JavaScript
    5. 2.5. EJS
    6. 2.6. HTML
    7. 2.7. Css
    8. 2.8. Stylus
    9. 2.9. Markdown
      1. 2.9.1. One empty line above the title(#,##,##…).
      2. 2.9.2. Use pre instead of images to show diagrams.For instance:
  3. 3. OS specific code styles
    1. 3.1. Windows
    2. 3.2. macOS
    3. 3.3. Linux
  4. 4. Platform specific code styles
    1. 4.1. Windows
    2. 4.2. iOS
    3. 4.3. Android

General code style

Clarity

You have to make sure it is easy for other people to read your code,for example:

// This code is bad because others won't know what btn1 does.
Button btn1 = new Button();
// This code is good because others will know that buttonLogin is for login action.
Button buttonLogin = new Button();
// This code is misleading because it looks like both statements
// are inside the conditional.
if (condition)
  firstStatement();
  secondStatement();
// Much clearer!
if (condition) {
  firstStatement();
}

secondStatement();

Language specific code styles

PHP

Objective-C

Java

JavaScript

EJS

HTML

Css

Stylus

Markdown

One empty line above the title(#,##,##…).

Use pre instead of images to show diagrams.For instance:

   |                            |                    |
---|--> Third party libraries --|--> Encapsulation --|---> Project
   |                            |                    |

OS specific code styles

Windows

macOS

Linux

Platform specific code styles

Windows

iOS

Android

没有任何评论