- 
                Notifications
    You must be signed in to change notification settings 
- Fork 0
Writing the Code
        Chloe edited this page May 9, 2024 
        ·
        2 revisions
      
    - While there is no strict coding style, it's important to maintain consistency → Instead look at and follow the structure of the existing code to keep it consistent.
- Whitespace Management: Please remove trailing whitespaces as they can lead to unnecessary changes in version control and can affect readability.
- Descriptive Naming: Choose names that clearly describe the purpose of the variable, function, or class. Avoid cryptic names that can end up unclear to other team members.
- 
Function Names: Make function names descriptive and action-oriented. Examples include:
- 
get_gene_name()— Indicates retrieval of a name.
- 
find_downstream_feature()— Suggests searching for a feature.
- 
is_circular()— Checks for a circular condition.
- 
has_multiple_flurbs()— Tests the existence of multiple flurbs.
 
- 
- 
Loop Variables: Use simple names like i,j, andkfor short-lived loop counters.
- 
Broad Scope Variables: Use more informative names for variables with a broader scope to enhance understanding and maintainability, such as filename_map,common_prefix,current_gene,feature_length.
- Purpose of Comments: Focus on 'why' something is done, rather than 'what' is done. The code should be self-explanatory; comments should explain rationale, context, or intent.
- Clarifying Complex Code: Whenever a piece of code is not "self-explanatory" or contains complex logic, go ahead and add a comment explaining its purpose and how it works.
- Documentation for Onboarding: Commenting are also for the new developers, since they can provide a guidance and understanding to understand the codebase more effectively.
- Consistent Indentation: Maintain consistent indentation levels across all code files to ensure that the code is organized and easy to read, or simply lint the code.
- Clarity Over Efficiency: Prefer clear, understandable code over compact, complex code. If a less optimal approach is clearer, document any efficiency trade-offs.
- Line Length: Keep lines to a maximum of 75-80 characters if you can. This makes it more readable and helps make side-by-side views in code reviews easier to do.
- Regular Refactoring: If it's possible, do a refactoring sessions to improve code design.
- 
Refactoring Techniques:
- Extract method
- Rename for clarity
- Reduce parameters
 
- Adherence to Standards: Follow established coding standards and practices.
- Google has a good set of best practices for bunch of different programming languages.