Good Code
The good version names the function and intermediate values after the business idea, so the scoring rule can be read without reverse engineering attributes.
Lesson 01
Use names and small functions that explain intent without forcing reviewers to decode abbreviations.
def calculate_review_score(review):
comment_score = len(review.comments) * 2
approval_score = review.approvals * 5
return comment_score + approval_scoredef calc(x):
a = len(x.c) * 2
b = x.a * 5
return a + bThe good version names the function and intermediate values after the business idea, so the scoring rule can be read without reverse engineering attributes.
The bad version hides the domain behind calc, x, a, b, and short attribute names. It may work, but the reviewer has to decode it before checking correctness.