C# ‐ Coding Standards, Principles, Practices - FullstackCodingGuy/Developer-Fundamentals GitHub Wiki

Practices

Remove Redundant State

  • Avoid storing inbound parameter objects as fields inside the implementation class. Instead, pass them as method parameters. This makes the class stateless and thread-safe.

Extract Common Logic

  • Move validation and transformation logic to reusable static methods or helper classes if they are shared across rules.

Reduce Logging Noise

  • Log only errors or important milestones, not every step, unless needed for debugging.

Use Expression-bodied Members

  • For simple property getters.

Minimize Exception Handling

  • Let exceptions bubble up unless you need to add context or handle specific cases.