-
Notifications
You must be signed in to change notification settings - Fork 0
Coding Guidelines
Kantapon Hemmadhun edited this page Nov 6, 2024
·
16 revisions
Follow flake8 coding style with
flake8flake8-docstring
def calculate_area(radius):
"""Calculate the area of a circle given its radius.
Args:
radius (float): The radius of the circle.
Returns:
float: The area of the circle.
"""
if radius < 0:
raise ValueError("Radius cannot be negative")
return 3.14159 * radius ** 2Avoid duplicating code. If you find yourself repeating similar code in different parts of the project, refactor it into reusable functions, classes, or mixings.
from django.db import models
class Author(models.Model):
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
date_of_birth = models.DateField()
date_of_death = models.DateField(null=True, blank=True)
def __str__(self):
return f"{self.first_name} {self.last_name}"Use built-in libraries and standard functions instead of recreating them. Prefer well-tested third-party libraries for common tasks.
from django.contrib.auth.decorators import login_required
@login_required
def dashboard(request):
return render(request, 'dashboard.html')- Query optimization
- Error Handling
- Sensitive data settings
- Testing
- Resolve conflicts with group review and merge.
- issue format
- merge request format