Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patchwork PR: GenerateStyle #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions style.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Code Style Guidelines

## 1. Naming Conventions
- Use descriptive and meaningful names for variables, functions, and classes.
- Follow camelCase for variables and functions, PascalCase for classes.
- Use UPPER_CASE for constants.
- Prefix private members with an underscore (_).

## 2. Code Structure
- Keep functions short and focused on a single task.
- Limit line length to 80-100 characters for improved readability.
- Use consistent indentation (preferably 2 or 4 spaces).
- Group related code together and separate different functionalities with blank lines.
- Follow the principle of separation of concerns.

## 3. Documentation
- Write clear and concise comments for complex logic or non-obvious code.
- Use docstrings for functions, classes, and modules, describing purpose, parameters, and return values.
- Keep comments up-to-date with code changes.
- Include a README file with project overview, setup instructions, and usage examples.

## 4. Error Handling
- Use try-except blocks to handle exceptions gracefully.
- Provide informative error messages for caught exceptions.
- Avoid catching generic exceptions; be specific about what errors to catch.
- Log errors and exceptions for debugging purposes.

## 5. Performance
- Optimize code for readability first, then for performance if necessary.
- Use appropriate data structures and algorithms for efficient operations.
- Avoid unnecessary computations or function calls in loops.
- Profile code to identify and address performance bottlenecks.

## 6. Security
- Validate and sanitize all user inputs to prevent injection attacks.
- Use parameterized queries for database operations to prevent SQL injection.
- Implement proper authentication and authorization mechanisms.
- Follow the principle of least privilege when designing system access.
- Keep sensitive information (e.g., API keys, passwords) out of source code.

## 7. Version Control
- Use meaningful commit messages that describe the changes made.
- Make small, focused commits rather than large, multi-purpose ones.
- Use feature branches for developing new features or major changes.
- Regularly merge or rebase with the main branch to stay up-to-date.

## 8. Testing
- Write unit tests for individual components and functions.
- Aim for high test coverage, especially for critical parts of the codebase.
- Include integration tests for testing component interactions.
- Run tests automatically as part of the CI/CD pipeline.

## 9. Code Review
- Conduct regular code reviews to ensure code quality and knowledge sharing.
- Use a checklist for code reviews to ensure consistency.
- Provide constructive feedback and be open to receiving it.
- Address all review comments before merging code.

## 10. Maintenance
- Regularly refactor code to improve its structure and readability.
- Keep dependencies up-to-date and regularly check for security vulnerabilities.
- Remove dead code and unused variables/imports.
- Document technical debt and plan for its resolution.