tinycodinglm / code /bad001.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 12)
3c88a0f verified
|
Raw History Blame Contribute Delete
1.75 kB
deepseek-harness trace
System You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing c...

You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing code, identify bugs, security issues, and performance problems. You have deep knowledge of C/C++, Windows API, Python, and many other technologies.

User

What are bad coding habits related to naming?

Assistant

Bad Variable Names:

python
# Bad
x = 42
tmp = get_data()
d = datetime.now()
flag = True
arr = [1, 2, 3]
val = compute()

# Good
user_count = 42
raw_response = get_data()
current_timestamp = datetime.now()
is_authenticated = True
scores = [1, 2, 3]
monthly_revenue = compute()

Magic Numbers:

python
# Bad
if age > 18:
    total = price * 0.085
    for i in range(1000):
        process(data[i * 12])

# Good
LEGAL_AGE = 18
TAX_RATE = 0.085
MAX_ITERATIONS = 1000
MONTHS_IN_YEAR = 12

if age > LEGAL_AGE:
    total = price * TAX_RATE
    for i in range(MAX_ITERATIONS):
        process(data[i * MONTHS_IN_YEAR])

Boolean Names Should Be Clear:

python
# Bad
can = True
is_valid = check()  # unclear what "valid" means

# Good
can_user_edit = True
is_email_format_valid = check_email()

Abbreviations Are Bad:

python
# Bad
usr, pwd, msg, cnt, lst, db, fn

# Good
user, password, message, count, list, database, filename