这份编码风格指南旨在为 ABC Compute Forum 社区的开发者提供一个统一的编码标准,以确保代码的可读性、可维护性和一致性。

语言风格

  • 中文:本文档默认使用中文进行描述。
  • English:If you are viewing this in English, you can find the English version of the coding style guide here.

格式规范

代码缩进

使用 4 个空格进行缩进。

def function():
    if condition:
        print("Hello, World!")

变量命名

  • 使用驼峰命名法(camelCase)。
  • 避免使用缩写或缩写词。
def getUserData():
    username = "John Doe"
    return username

函数命名

  • 使用动词开头,描述函数的功能。
  • 避免使用缩写或缩写词。
def calculateSum(a, b):
    return a + b

类命名

  • 使用驼峰命名法(camelCase)。
  • 类名应该以大写字母开头。
class User:
    def __init__(self, username, email):
        self.username = username
        self.email = email

图片示例

以下是一些编程语言的示例代码:

# Python
def function():
    print("Hello, World!")

# Java
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

# JavaScript
function function() {
    console.log("Hello, World!");
}

Python
Java
JavaScript

扩展阅读

更多关于编码风格的信息,请参阅我们的 编码规范文档

# Coding Style Guide

This coding style guide aims to provide ABC Compute Forum community developers with a unified coding standard to ensure code readability, maintainability, and consistency.

## Language Style

- **Chinese**: This document is described in Chinese by default.
- **English**: If you are viewing this in English, you can find the English version of the coding style guide [here](/community/abc_compute_forum/coding_style_guide/en).

## Format Specifications

### Code Indentation

Use 4 spaces for indentation.

```python
def function():
    if condition:
        print("Hello, World!")

Variable Naming

  • Use camelCase.
  • Avoid abbreviations or acronyms.
def getUserData():
    username = "John Doe"
    return username

Function Naming

  • Start with a verb, describing the function's functionality.
  • Avoid abbreviations or acronyms.
def calculateSum(a, b):
    return a + b

Class Naming

  • Use camelCase.
  • Class names should start with an uppercase letter.
class User:
    def __init__(self, username, email):
        self.username = username
        self.email = email

Image Examples

Here are some examples of code in programming languages:

# Python
def function():
    print("Hello, World!")

# Java
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

# JavaScript
function function() {
    console.log("Hello, World!");
}

Python
Java
JavaScript

Further Reading

For more information on coding style, please refer to our Coding Standards Document.