Roadmap › Clean Code, Testing & Best Practices › Module: Readable Code
Lessons in this course (12)

1. Naming

Basic★ Must knowLesson 1 of 12
  • Names reveal intent: daysSinceLastLogin, not d or data2.
  • Classes = nouns (InvoiceCalculator); methods = verbs (CalculateTotal, SendReminder).
  • Booleans read as questions: isActive, hasAccess, canRetry.
  • Avoid noise words: Manager, Processor, Data, Info (unless they really mean something).
  • .NET conventions: PascalCase for types, methods, properties, constants; camelCase for locals and parameters; _camelCase for private fields; I prefix for interfaces; Async suffix for async methods.
csharp
// ❌
public List<int> Get(List<int> l) { var r = new List<int>(); foreach (var x in l) if (x % 2 == 0) r.Add(x); return r; }
// ✅
public IReadOnlyList<int> GetEvenNumbers(IEnumerable<int> numbers) => numbers.Where(n => n % 2 == 0).ToList();