Skip to content

Code Style Document

Valk edited this page Sep 25, 2024 · 36 revisions

C# Coding Guidelines

General Guidelines

  • Adhere to SRP, DRY and SoC principles
  • Avoid over engineering code
  • Use Encapsulation to hide what others should not see
  • Prefer Composition over Inheritance
  • Use Abstraction
  • Create Context classes for methods with more than 2 parameters

Formatting

  • Indentation: 4 spaces.
  • Curly Braces: Always expand.
  • Using Directives: Above namespace.

Naming

  • PascalCase: Types, methods, properties, constants, events.
  • camelCase: Private fields, local variables, method args.
  • Prefixes: On for events, Set for set methods, Get for get methods

Language Features

  • Static Functions: Use when possible.
  • CallDeferred(): Avoid if alternatives exist.
  • var Keyword: Do not use ever.
  • C# Delegate Events: Always use over Godot signals.
  • Explicit Private Modifiers: Always specify private.

Commit Practices

  • Commit Separation: Separate large indentation changes.
Clone this wiki locally