Skip to content

Coding Style Guide

This document outlines the coding style guide for the Loki project. Please follow these guidelines when contributing code changes.

General Guidelines

  • Use clear and concise variable, function, and class names.
  • Use descriptive comments to explain complex or non-obvious parts of the code.
  • Use consistent indentation (4 spaces).
  • Use consistent spacing (e.g., around operators, after commas, etc.).
  • Use consistent capitalization for variable, function, and class names.

Naming Conventions

  • Use lowerCamelCase for variable names.
  • Use UpperCamelCase for class and function names.
  • Use ALL_CAPS for constants.

Code Formatting

  • Use consistent indentation (4 spaces).
  • Use consistent line length (80 characters).
  • Use consistent spacing (e.g., around operators, after commas, etc.).
  • Use a single blank line between functions and classes.
  • Use a single blank line between logical sections of code.

Comments

  • Use descriptive comments to explain complex or non-obvious parts of the code.
  • Use block comments for function and class descriptions.
  • Use inline comments sparingly, only when necessary.

Error Handling

  • Use exceptions for error handling.
  • Use descriptive error messages.
  • Catch and handle exceptions gracefully.

Versioning

  • Code should be versioned along with the documentation.
  • Use the appropriate version tag in the code file name or URL.

Review Process

  • All code changes should be reviewed by at least one other contributor before merging.
  • Use GitHub pull requests to submit and review code changes.

Please follow these guidelines when contributing to our codebase. If you have any questions or suggestions, please open an issue on our GitHub repository.

An easy way to ensure this is to simply run

dotnet format loki.sln
dotnet format loki.csproj

In a command shell at the project's root folder