No puede seleccionar más de 25 temas
Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
Skill 05 - Functions, Debugging, and Testing
Function Design
- Follow DRY, but do not abstract too early.
- Keep functions small enough to explain in one sentence.
- Prefer pure functions for business rules when possible.
- Make side effects obvious in names and placement.
- Use parameters for required input and return values for computed output.
- Use tuples for small local groupings; use named types for public APIs or durable concepts.
Async Rules
- Use
Task/Task<T> for asynchronous operations.
- Suffix asynchronous methods with
Async.
- Pass
CancellationToken through I/O or long-running operations.
- Never use
.Result or .Wait() in request-handling or UI code.
Debugging Rules
- Reproduce the issue first.
- Use breakpoints, watches, locals, call stack, and trace/log output.
- Verify assumptions with tests rather than comments alone.
- Remove temporary diagnostic output before final code unless it becomes structured logging.
Unit Testing Rules
- Use Arrange, Act, Assert.
- Test normal, boundary, invalid, and null cases.
- Unit-test pure logic without external services.
- Integration-test database, filesystem, HTTP, serialization, and DI wiring.
- Keep tests deterministic. Avoid reliance on local time, random values, order, or environment unless controlled.
Common Commands
dotnet test
dotnet test --filter FullyQualifiedName~SomeTestName
dotnet test --collect:"XPlat Code Coverage"