talk2data / .cursor /rules /coding-standards.mdc
cevheri's picture
docs: add cursor rules
95d6173
raw
history blame
3.46 kB
---
description:
globs:
alwaysApply: false
---
# Coding Standards
This document outlines the coding standards for the AI-powered database interface, emphasizing the use of English in all code-related content and adherence to SOLID principles, Clean Code, and Design Patterns.
## Language Consistency
### Comments and Notes
- All comments and notes must be written in English.
- Avoid using any language other than English in code comments.
- Ensure clarity and conciseness in comments to aid understanding.
### Variable and Function Naming
- Use English for all variable and function names.
- Follow a consistent naming convention (e.g., camelCase, snake_case).
- Avoid using non-English characters or words in identifiers.
### Documentation
- All documentation, including README files and inline documentation, should be in English.
- Ensure that all code examples and explanations are clear and accessible to English-speaking developers.
## Best Practices
### Code Readability
- Write clear and descriptive comments.
- Use meaningful variable and function names.
- Maintain a consistent style throughout the codebase.
### Collaboration
- Encourage team members to adhere to these standards.
- Regular code reviews to ensure compliance with language consistency.
- Provide feedback and support for maintaining these standards.
## SOLID Principles
### Single Responsibility Principle (SRP)
- Each class should have only one reason to change.
- Ensure that classes are focused on a single functionality.
### Open/Closed Principle (OCP)
- Software entities should be open for extension but closed for modification.
- Use inheritance and polymorphism to extend functionality.
### Liskov Substitution Principle (LSP)
- Subtypes must be substitutable for their base types.
- Ensure that derived classes can replace base classes without affecting the correctness of the program.
### Interface Segregation Principle (ISP)
- Clients should not be forced to depend on interfaces they do not use.
- Design interfaces to be specific to client needs.
### Dependency Inversion Principle (DIP)
- High-level modules should not depend on low-level modules. Both should depend on abstractions.
- Use dependency injection to manage dependencies.
## Clean Code
### Meaningful Names
- Use descriptive names for variables, functions, and classes.
- Avoid abbreviations and unclear names.
### Functions
- Functions should be small and do one thing.
- Use descriptive names and avoid side effects.
### Comments
- Comments should explain why, not what.
- Avoid unnecessary comments and ensure they are up-to-date.
### Formatting
- Maintain consistent formatting and indentation.
- Use whitespace effectively to improve readability.
## Design Patterns
### Creational Patterns
- Use patterns like Singleton, Factory, and Builder to manage object creation.
### Structural Patterns
- Use patterns like Adapter, Bridge, and Composite to manage relationships between objects.
### Behavioral Patterns
- Use patterns like Observer, Strategy, and Command to manage communication between objects.
## Compliance
### Review Process
- Regular audits of the codebase to ensure adherence to language standards and design principles.
- Address any deviations promptly to maintain consistency.
### Training
- Provide training and resources to help team members understand and follow these standards.
- Encourage continuous learning and improvement in coding practices.