-
Notifications
You must be signed in to change notification settings - Fork 9
Code Style Document
Valk edited this page Sep 24, 2024
·
36 revisions
- Avoid duplicate code.
- Avoid over engineering code.
- Classes / functions should have one responsibility.
- Separation concerns. Divide the program into distinct sections, each addressing a separate concern.
- Hide the internal state and functionality of an object and only allow access through a public set of functions
- Try to make the code modular
- Composition over Inheritance
- Abstraction
- Indentation: 4 spaces.
- Curly Braces: Always expand.
- Using Directives: Above namespace.
- 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
- 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 Separation: Separate large indentation changes.