-
Notifications
You must be signed in to change notification settings - Fork 0
Writing the Code
Chloe edited this page Apr 29, 2024
·
2 revisions
- There is no strict coding style, just follow the structure of the code around it
- Remove trailing whitespaces
NAME OF IT
- Opt for clarity and descriptiveness over being cryptic
- Function names could be action-oriented or pose questions:
get_gene_name()
,find_downstream_feature()
,is_circular()
, orhas_multiple_flurbs()
- For simple loop variables:
i
,j
, andk
- Variables with broader scopes use informative names:
filename_map
,common_prefix
,current_gene
,feature_length
, etc.
-
Why
overwhat
comments, as that should be clear from the code alone. - If something is confusing or hard to understand, add a comment to explain it.
- Docment anything that would be needed to onboard someone.
- Keep the indentation consistent throughout the entire codebase.
-
Clarify + less optimal
>cryptic + more efficient
- Document the cryptic approach or do it the other way around and leave a comment highlighting any trade-offs or compromises made.
- Optimise readability and comprehension.
- Avoid excessively long lines, especially those exceeding 75-80 characters.
- Makes it more readable.
- Makes pull requests smaller.
- Google has a good set of best practices for bunch of different programming languages.