Skip to content

Writing the Code

Chloe edited this page Apr 29, 2024 · 2 revisions

Coding style

  • There is no strict coding style, just follow the structure of the code around it
  • Remove trailing whitespaces

Naming Conventions and Intent

  • 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(), or has_multiple_flurbs()
  • For simple loop variables: i, j, and k
  • Variables with broader scopes use informative names: filename_map, common_prefix, current_gene, feature_length, etc.

Leaving Comments on the Code

  • Why over what 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.

Legibility of the Code

  • 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.

Best programming practices

  • Google has a good set of best practices for bunch of different programming languages.
Clone this wiki locally