Coding Standard guideline - TAGCH/Workflow-Automation GitHub Wiki
This wiki page contain a coding standard for this project.
- Example:
frontend-workflow-creation
- variable: snake_case(lower_case_with_underscore) or UPPER_CASE_WITH_UNDERSCORE
- class name: PascalCase
- Always use a meaningful name for variable, method and class.
- In case there is a need for magic number in the code, create a variable for that number with it purposed name.
Example.# magic number exist balance_in_thb = 1000 balance_in_usd = balance_in_thb * 0.028 print(balance_in_usd)
# change it to meaningful variable balance_in_thb = 1000 baht_to_usd_converter = 0.028 balance_in_usd = balance_in_thb * baht_to_usd_converter print(balance_in_usd)
We will follow ISP style, which is similar to sphinx style, but use type hints for parameter instead.
def average(values: Collection[float|int]) -> float:
"""Compute the arithmetic average of a collection of values.
:param values: non-empty collection of numeric values to average
:returns: the population average of the values
:raises ValueError: if collection is empty or contains invalid values
"""
"""A bank account that performs deposits and withdrawals."""
from re import split
from money import Money
class BankAccount:
"""The first line is a sentence describing bank account.
Then a longer description of a bank account and its methods.
"""
def __init__(self, name, min_balance=0):
"""Create a new bank account with an owner and initial balance of zero.
Parameters:
name (str): name of the account
min_balance (float): minimum required balance, default is 0.
"""
1. PyLint : checking code according to PEP8
2. Flake8 : is coding style for Django Framework
- Variables and Functions:
Use camelCase for variable and function names.
let workflowStatus = 'active';
const handleUserLogin = () => { ... };
Avoid abbreviations unless they are widely understood (e.g., id, URL).
- React Components and Pages:
Component and Pages names should follow PascalCase.
WorkflowPage.js
const WorkflowPage = () => { ... };