Code Style & Formatting

This outline details the code style and formatting conventions used in the codebase, ensuring consistency and readability.

General Principles

  • Indentation: Use four spaces for indentation.
  • Line Length: Limit lines to a maximum of 120 characters.
  • Brace Placement: Place opening braces on the same line as the declaration.
  • Spacing: Use a single space after keywords, operators, and commas.
  • Naming Conventions:
    • Classes and Interfaces: PascalCase.
    • Methods, Properties, and Fields: PascalCase.
    • Variables: camelCase.
    • Constants: UpperCase.
  • Comments: Use clear and concise comments to explain complex logic or intent.
  • Redundancy: Avoid unnecessary code duplication.

Code Examples

Formatting

// Example of indentation and brace placement
          public class MyClass
          {
              public int MyMethod(string arg1, int arg2)
              {
                  // Example of line length and spacing
                  if (arg1.Length > 10 && arg2 > 5)
                  {
                      return arg2 * 2;
                  }
                  else
                  {
                      return 0;
                  }
              }
          }
          

Naming Conventions

// Example of class, method, and variable naming
          public class MyCalculator
          {
              private int _currentNumber;
          
              public int Add(int number1, int number2)
              {
                  return number1 + number2;
              }
          
              public const int MAX_NUMBER = 100;
          }
          

Comments

// Example of comments explaining complex logic
          public int CalculateDiscount(int price)
          {
              // Apply a 10% discount if the price is greater than $100
              if (price > 100)
              {
                  return price * 0.9;
              }
              else
              {
                  return price;
              }
          }
          

Resources

Contributing

Follow the conventions outlined above when contributing to the codebase. Maintain consistency and readability for a cohesive and maintainable project.


          ## Top-Level Directory Explanations
          
          <a class='local-link directory-link' data-ref="obj/" href="#obj/">obj/</a> - Temporary directory that stores compiled intermediate files during the build process.
          
          <a class='local-link directory-link' data-ref="obj/Debug/" href="#obj/Debug/">obj/Debug/</a> - Temporary directory for debug versions of the compiled intermediate files.
          
          <a class='local-link directory-link' data-ref="obj/Debug/net6.0/" href="#obj/Debug/net6.0/">obj/Debug/net6.0/</a> - Temporary directory for debug versions of the compiled intermediate files for .NET 6.0.