tinycodinglm / code /bad002.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 12)
3c88a0f verified
|
Raw History Blame
1.96 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 common anti-patterns and code smells?

Assistant

Code Smells:

  • Long methods (>50 lines)
  • Large classes (>500 lines)
  • Deep nesting (3+ levels)
  • Duplicated code
  • Long parameter lists (>3 parameters)
  • Dead code (unused variables, unreachable code)
  • God objects (do everything)

Anti-Patterns:

  1. Spaghetti Code: No structure, tangled logic
python
# Bad: everything in one function

    # 200 lines of mixed logic
  1. Golden Hammer: Using same tool for everything
python
# Bad: regex for HTML parsing
re.findall(r'<div>(.*?)</div>', html)
  1. Copy-Paste Programming: Duplicated logic
python
# Bad: same validation everywhere
if age >= 18 and age <= 65 and country == "US": ...
# repeated 10 times
  1. Premature Optimization: Optimizing before needed
python
# Bad: complex cache for simple operation
@lru_cache(maxsize=1024)
def add(a, b): return a + b
  1. Lava Flow: Dead code that nobody dares remove

  2. Shotgun Surgery: One change requires many edits

  3. Feature Envy: Method uses another class's data more than its own

  4. Primitive Obsession: Using primitives instead of small objects

python
# Bad
name = "John"
age = 30
# Better: use a Person class