tinycodinglm / code /bad001.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 12)
3c88a0f verified
|
Raw History Blame
1.75 kB
{"type": "session", "harness": "deepseek-harness", "id": "bad001", "name": "Bad variable naming and magic numbers"}
{"type": "message", "message": {"role": "system", "content": "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."}}
{"type": "message", "message": {"role": "user", "content": "What are bad coding habits related to naming?"}}
{"type": "message", "message": {"role": "assistant", "content": "**Bad Variable Names:**\n```python\n# Bad\nx = 42\ntmp = get_data()\nd = datetime.now()\nflag = True\narr = [1, 2, 3]\nval = compute()\n\n# Good\nuser_count = 42\nraw_response = get_data()\ncurrent_timestamp = datetime.now()\nis_authenticated = True\nscores = [1, 2, 3]\nmonthly_revenue = compute()\n```\n\n**Magic Numbers:**\n```python\n# Bad\nif age > 18:\n total = price * 0.085\n for i in range(1000):\n process(data[i * 12])\n\n# Good\nLEGAL_AGE = 18\nTAX_RATE = 0.085\nMAX_ITERATIONS = 1000\nMONTHS_IN_YEAR = 12\n\nif age > LEGAL_AGE:\n total = price * TAX_RATE\n for i in range(MAX_ITERATIONS):\n process(data[i * MONTHS_IN_YEAR])\n```\n\n**Boolean Names Should Be Clear:**\n```python\n# Bad\ncan = True\nis_valid = check() # unclear what \"valid\" means\n\n# Good\ncan_user_edit = True\nis_email_format_valid = check_email()\n```\n\n**Abbreviations Are Bad:**\n```python\n# Bad\nusr, pwd, msg, cnt, lst, db, fn\n\n# Good\nuser, password, message, count, list, database, filename\n```"}}