Skip to content

Guidelines

NSpahic22 edited this page Oct 8, 2024 · 2 revisions

Code Structure & Organization

  • Consistent Naming: Use PascalCase for classes, camelCase for variables.
  • Keep Files Focused: Each file should serve a single purpose.
  • Group Related Endpoints: Organize endpoints by resource type.

Readability & Documentation

  • Descriptive Names: Use clear names for functions, classes, and variables.
  • Comment Wisely: Explain why, not what.
  • Document APIs: Use Swagger for endpoint documentation.

Error Handling

  • Try-Catch for Exceptions: Handle exceptions in critical areas.
  • Meaningful Error Messages: Informative yet secure.
  • Avoid Sensitive Data in Errors: Don’t expose internal details.

Coding Practices

  • DRY Principle: Reuse code to avoid redundancy.
  • Use Dependency Injection: Keep code modular and testable.
  • Avoid Magic Numbers: Use named constants or enums.

Data & Security

  • Validate Input: Always validate user inputs.
  • Use HTTPS: Encrypt data in transit.
  • Implement Authentication/Authorization: Secure your endpoints.

Performance

  • Asynchronous Calls: Use async/await for non-blocking tasks.
  • Paginate Data: Avoid large payloads.
  • Cache Repeated Calls: Cache frequently accessed data.

Testing & Debugging

  • Write Tests: Unit tests for logic, integration tests for endpoints.
  • Use Logging: Log key actions for easier debugging.

Version Control

  • Descriptive Commits: Make commit messages meaningful.
  • Use Feature Branches: Isolate new features and fixes.
  • Code Reviews: Improve quality and team collaboration.
Clone this wiki locally