tinycodinglm / code /bad004.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 12)
3c88a0f verified
|
Raw History Blame Contribute Delete
2.09 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 code organization habits?

Assistant

Bad Habits:

  1. God Files (1000+ lines):
python
# Bad: everything in one file
# utils.py: 3000 lines of unrelated functions

# Good: separate by concern
# auth.py, database.py, api.py, models.py
  1. Circular Imports:
python
# Bad
# a.py
from b import something
# b.py
from a import something_else
  1. Deeply Nested Files:
markdown
src/utils/helpers/validators/email/checkers/format.py

Should be: src/validators/email_format.py

  1. No Module Structure:
markdown
# Bad
project/
  stuff.py
  more_stuff.py
  test_stuff.py

# Good
project/
  src/
    __init__.py
    models.py
    services.py
  tests/
    test_models.py
  requirements.txt
  1. Hardcoded Configuration:
python
# Bad
db = connect("localhost", 5432, "user", "password123")

# Good
import os
db = connect(
    os.getenv("DB_HOST"),
    int(os.getenv("DB_PORT", 5432)),
    os.getenv("DB_USER"),
    os.getenv("DB_PASS")
)
  1. Mixing Levels of Abstraction:
python
# Bad
def process():
    raw = read_file()
    lines = raw.split('
')
    data = [json.loads(l) for l in lines if l]
    for item in data:
        db.insert(item)  # mixes I/O, parsing, and storage

# Good: separate concerns
def process():
    raw = read_file()
    data = parse_lines(raw)
    store_data(data)