View Code? Open in Web Editor
NEW
Coding Best Practices and Principles
clean_code's Introduction
Clean Code Best Practices
- Keep functions concise, ideally not exceeding 60 lines.
- Employ interfaces for repositories.
- Prefer composition over inheritance when connecting classes for creating complex structures.
- Utilize records for defining data models.
- Consider using concurrency mechanisms over traditional multithreading approaches.
- Don't use comments in your code; prioritize writing self-explanatory code.
- Don't use a try-catch block; implement global exception handling.
- Embrace object-oriented programming (OOP) principles but prioritize "Functional Programming" paradigms.
- Keep functions concise, ideally limited to 60 lines.
- Enhance code readability by incorporating type hints.
- Utilize Pydantic for robust data validation.
- Consider leveraging asynchronous programming for improved performance.
- Don't use comments in your code; prioritize writing self-explanatory code.
- Don't use a try-catch block; implement global exception handling.
- Avoid designing APIs with bulk payloads; break down the API into smaller components.
- Implement API versions to manage changes and updates effectively.
- Utilize throttling mechanisms to control the number of requests the API can process.
- Implement rate-limiting strategies to regulate how frequently the API can be accessed.
- Implement caching (Save frequently used data to speed up responses).
- Implement connection pooling (Reuse existing database connections to save time and resources).
- DRY (Don't repeat yourself)
- KISS (Keep it simple stupid)
clean_code's People
Contributors
Watchers