{"id":13411710,"url":"https://github.com/trekhleb/state-of-the-art-shitcode","last_synced_at":"2025-05-14T10:09:21.700Z","repository":{"id":37408434,"uuid":"236586917","full_name":"trekhleb/state-of-the-art-shitcode","owner":"trekhleb","description":"💩State-of-the-art shitcode principles your project should follow to call it a proper shitcode","archived":false,"fork":false,"pushed_at":"2024-07-07T21:22:29.000Z","size":64,"stargazers_count":5869,"open_issues_count":47,"forks_count":326,"subscribers_count":50,"default_branch":"master","last_synced_at":"2025-04-02T09:01:32.330Z","etag":null,"topics":["best-practice","best-practices","code-quality","coding","javascript","principles","programming","style-guides","styleguide"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trekhleb.png","metadata":{"files":{"readme":"README.ko-KR.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"trekhleb","patreon":"trekhleb"}},"created_at":"2020-01-27T20:25:33.000Z","updated_at":"2025-04-01T05:32:18.000Z","dependencies_parsed_at":"2023-01-31T18:31:37.345Z","dependency_job_id":"6703e2b1-960a-4a39-8c36-60198985266a","html_url":"https://github.com/trekhleb/state-of-the-art-shitcode","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trekhleb%2Fstate-of-the-art-shitcode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trekhleb%2Fstate-of-the-art-shitcode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trekhleb%2Fstate-of-the-art-shitcode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trekhleb%2Fstate-of-the-art-shitcode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trekhleb","download_url":"https://codeload.github.com/trekhleb/state-of-the-art-shitcode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248027395,"owners_count":21035594,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["best-practice","best-practices","code-quality","coding","javascript","principles","programming","style-guides","styleguide"],"created_at":"2024-07-30T20:01:16.054Z","updated_at":"2025-04-09T11:02:12.195Z","avatar_url":"https://github.com/trekhleb.png","language":null,"funding_links":["https://github.com/sponsors/trekhleb","https://patreon.com/trekhleb"],"categories":["Others","miscellaneous","Uncategorized","计算机编程_数据结构与算法"],"sub_categories":["Uncategorized","资源传输下载"],"readme":"# State-of-the-Art Shitcode의 규칙\n\n[![State-of-the-art Shitcode](https://img.shields.io/static/v1?label=State-of-the-art\u0026message=Shitcode\u0026color=7B5804)](https://github.com/trekhleb/state-of-the-art-shitcode)\n\n이 목록은 여러분의 프로젝트가 제대로 shitcode가 되기 위해 따라야 하는 규칙들입니다.\n\n_다른 언어로 읽기:_\n[_English_](README.md),\n[_简体中文_](README.zh-CN.md)\n\n## 뱃지 만들기\n\n만일 여러분의 레포지토리가 shitcode의 규칙을 따른다면, 여러분은 다음과 같은 \"state-of-the-art shitcode\" 뱃지를 사용할 수 있습니다:\n\n[![State-of-the-art Shitcode](https://img.shields.io/static/v1?label=State-of-the-art\u0026message=Shitcode\u0026color=7B5804)](https://github.com/trekhleb/state-of-the-art-shitcode)\n\n뱃지를 만들기 위한 마크다운 소스코드:\n\n```\n[![State-of-the-art Shitcode](https://img.shields.io/static/v1?label=State-of-the-art\u0026message=Shitcode\u0026color=7B5804)](https://github.com/trekhleb/state-of-the-art-shitcode)\n```\n\n## 규칙\n\n### 💩 변수 이름 애매하게 지정하기\n\n적은 키 입력은, 여러분의 시간을 아끼게 해줍니다.\n\n_Good 👍🏻_\n\n```javascript\nlet a = 42;\n```\n\n_Bad 👎🏻_\n\n```javascript\nlet age = 42;\n```\n\n### 💩 변수와 함수의 이름 스타일을 섞기\n\n다양성을 축하합시다.\n\n_Good 👍🏻_\n\n```javascript\nlet wWidth = 640;\nlet w_height = 480;\n```\n\n_Bad 👎🏻_\n\n```javascript\nlet windowWidth = 640;\nlet windowHeight = 480;\n```\n\n### 💩 주석을 전혀 작성하지 않기\n\n어차피 아무도 당신의 코드를 읽지 않을 것입니다.\n\n_Good 👍🏻_\n\n```javascript\nconst cdr = 700;\n```\n\n_Bad 👎🏻_\n\n자주 작성되는 주석은 '왜'가 아니라 '무엇'인지를 포함해야 합니다. 만일 코드에서 '무엇'이 명확하지 않으면, 코드가 너무 흐트러질 수 있기 때문입니다.\n\n```javascript\n// 700ms라는 수는 UX A/B 테스트 결과에 기초하여 경험적으로 계산된 것입니다.\n// @보세요: \u003c실험 또는 JIRA 작업에 관련된 것 또는 숫자 700에 대해 상세히 설명하는 것에 대한 링크\u003e\nconst callbackDebounceRate = 700;\n```\n\n### 💩 항상 자신의 모국어로 주석을 작성하기\n\n만일 \"주석 없음\"의 원칙을 위반했다면 적어도 주석은 코드 작성에 사용하는 언어와 다른 언어로 작성하세요. 만일 여러분의 모국어가 영어라면 여러분은 이 원칙을 위반해도 괜찮습니다.\n\n_Good 👍🏻_\n\n```javascript\n// Закриваємо модальне віконечко при виникненні помилки.\ntoggleModal(false);\n```\n\n_Bad 👎🏻_\n\n```javascript\n// Hide modal window on error.\ntoggleModal(false);\n```\n\n### 💩 가능한 많이 서식 스타일을 혼합하기\n\n다양성을 축하합시다.\n\n_Good 👍🏻_\n\n```javascript\nlet i = ['tomato', 'onion', 'mushrooms'];\nlet d = [ \"ketchup\", \"mayonnaise\" ];\n```\n\n_Bad 👎🏻_\n\n```javascript\nlet ingredients = ['tomato', 'onion', 'mushrooms'];\nlet dressings = ['ketchup', 'mayonnaise'];\n```\n\n### 💩 가능한 많이 한 줄에 코드 입력하기\n\n_Good 👍🏻_\n\n```javascript\ndocument.location.search.replace(/(^\\?)/,'').split('\u0026').reduce(function(o,n){n=n.split('=');o[n[0]]=n[1];return o},{})\n```\n\n_Bad 👎🏻_\n\n```javascript\ndocument.location.search\n  .replace(/(^\\?)/, '')\n  .split('\u0026')\n  .reduce((searchParams, keyValuePair) =\u003e {\n    keyValuePair = keyValuePair.split('=');\n    searchParams[keyValuePair[0]] = keyValuePair[1];\n    return searchParams;\n  },\n  {}\n)\n```\n\n### 💩 조용히 실패하기\n\n오류가 발생할 때마다 다른 사람이 그 오류를 알 필요는 없습니다. 로그도 없고, 오류 모달도 없이, 싸늘하게.\n\n_Good 👍🏻_\n\n```javascript\ntry {\n  // 무언가 예견 불가능한 것.\n} catch (error) {\n  // 쉿... 🤫\n}\n```\n\n_Bad 👎🏻_\n\n```javascript\ntry {\n  // 무언가 예견 불가능한 것.\n} catch (error) {\n  setErrorMessage(error.message);\n  // and/or\n  logError(error);\n}\n```\n\n### 💩 전역 변수를 광범위하게 사용하기\n\n세계적인 원칙입니다.\n\n_Good 👍🏻_\n\n```javascript\nlet x = 5;\n\nfunction square() {\n  x = x ** 2;\n}\n\nsquare(); // 이제 x는 25입니다.\n```\n\n_Bad 👎🏻_\n\n```javascript\nlet x = 5;\n\nfunction square(num) {\n  return num ** 2;\n}\n\nx = square(x); // 이제 x는 25입니다.\n```\n\n### 💩 사용하지 않을 변수 만들기\n\n혹시 모르니까요.\n\n_Good 👍🏻_\n\n```javascript\nfunction sum(a, b, c) {\n  const timeout = 1300;\n  const result = a + b;\n  return a + b;\n}\n```\n\n_Bad 👎🏻_\n\n```javascript\nfunction sum(a, b) {\n  return a + b;\n}\n```\n\n### 💩 가능한 언어라면 타입지정 및/또는 타입검사 하지 않기\n\n_Good 👍🏻_\n\n```javascript\nfunction sum(a, b) {\n  return a + b;\n}\n\n// 형식이 없으면 신이 나요.\nconst guessWhat = sum([], {}); // -\u003e \"[object Object]\"\nconst guessWhatAgain = sum({}, []); // -\u003e 0\n```\n\n_Bad 👎🏻_\n\n```javascript\nfunction sum(a: number, b: number): ?number {\n  // 자바스크립트에서 반환 및/또는 타입검사를 하지 않은 경우를 커버하는 조건\n  if (typeof a !== 'number' \u0026\u0026 typeof b !== 'number') {\n    return undefined;\n  }\n  return a + b;\n}\n// 이 경우는 반환/컴파일의 경우에 실패할 것입니다.\nconst guessWhat = sum([], {}); // -\u003e undefined\n```\n\n### 💩 연결할 수 없는 코드 작성하기\n\n이 것이 여러분의 \"플랜 B\" 입니다.\n\n_Good 👍🏻_\n\n```javascript\nfunction square(num) {\n  if (typeof num === 'undefined') {\n    return undefined;\n  }\n  else {\n    return num ** 2;\n  }\n  return null; // 이 것이 나의 \"플랜 B\".\n}\n```\n\n_Bad 👎🏻_\n\n```javascript\nfunction square(num) {\n  if (typeof num === 'undefined') {\n    return undefined;\n  }\n  return num ** 2;\n}\n```\n\n### 💩 삼각형 규칙\n\n새처럼 되자 - 둥지를 틀자, 둥지를 틀자, 둥지를 틀자.\n\n_Good 👍🏻_\n\n```javascript\nfunction someFunction() {\n  if (condition1) {\n    if (condition2) {\n      asyncFunction(params, (result) =\u003e {\n        if (result) {\n          for (;;) {\n            if (condition3) {\n            }\n          }\n        }\n      })\n    }\n  }\n}\n```\n\n_Bad 👎🏻_\n\n```javascript\nasync function someFunction() {\n  if (!condition1 || !condition2) {\n    return;\n  }\n  \n  const result = await asyncFunction(params);\n  if (!result) {\n    return;\n  }\n  \n  for (;;) {\n    if (condition3) {\n    }\n  }\n}\n```\n\n### 💩 들여쓰기 망치기\n\n들여쓰기는 에디터에서 복잡한 코드의 공간을 더 차지하기 때문에 들여쓰기를 피합시다. 만약 피하고 싶지 않다면 그냥 그들을 엉망으로 가지고 노세요.\n\n_Good 👍🏻_\n\n```javascript\nconst fruits = ['apple',\n  'orange', 'grape', 'pineapple'];\n  const toppings = ['syrup', 'cream', \n                    'jam', \n                    'chocolate'];\nconst desserts = [];\nfruits.forEach(fruit =\u003e {\ntoppings.forEach(topping =\u003e {\n    desserts.push([\nfruit,topping]);\n    });})\n```\n\n_Bad 👎🏻_\n\n```javascript\nconst fruits = ['apple', 'orange', 'grape', 'pineapple'];\nconst toppings = ['syrup', 'cream', 'jam', 'chocolate'];\nconst desserts = [];\n\nfruits.forEach(fruit =\u003e {\n  toppings.forEach(topping =\u003e {\n    desserts.push([fruit, topping]); \n  });\n})\n```\n\n### 💩 dependencies 잠그지 않기 \n\n새로운 설치가 있을 때마다 제어되지 않는 방식으로 dependencies를 업데이트 하세요. 왜 과거에 집착하죠, 최첨단 라이브러리 버전을 사용합시다.\n\n_Good 👍🏻_\n\n```\n$ ls -la\n\npackage.json\n```\n\n_Bad 👎🏻_\n\n```\n$ ls -la\n\npackage.json\npackage-lock.json\n```\n\n### 💩 항상 boolean 타입 변수의 이름을 'flag'로 만들기\n\nboolean 값이 무엇을 의미하는지 동료들이 생각할 공간을 남겨둡시다.\n\n_Good 👍🏻_\n\n```javascript\nlet flag = true;\n```\n\n_Bad 👎🏻_\n\n```javascript\nlet isDone = false;\nlet isEmpty = false;\n```\n\n### 💩 길게 쓰인 function들이 짧은 것보다 낫다.\n\n프로그램 로직을 읽을 수 있는 조각으로 나누지 맙시다. 만일 여러분이 사용하는 IDE의 검색이 중단되고 필수적인 파일 또는 function을 찾을 수 없다면 어떻게 하겠습니까?\n\n- 한 개의 파일에 10000 줄의 코드가 있어도 괜찮습니다.\n- 한 개의 function에 1000 줄의 코드가 있어도 괜찮습니다.\n- 많은 서비스들 (써드파티와 내부기능, 몇몇 헬퍼들, ORM과 jQuery slider로 직접 작성된 자료들 ) 이 `service.js` 하나에 들어있다구요? 괜찮습니다.\n\n### 💩 작성한 코드를 테스트 해보는 것을 피하기\n\n이 것은 중복되고 불필요한 일의 양입니다.\n\n### 💩 최대한 code linter들을 피하려고 노력하기\n\n특히 둘 이상의 개발자가 있는 팀인 경우 원하는 대로 코드를 작성합니다. 이것은 '자유'의 규칙입니다.\n\n### 💩 README 파일이 없이 프로젝트 시작하기\n\n그리고 당분간은 그렇게 지내세요.\n\n### 💩 불필요한 코드가 필요합니다\n\n어플에서 사용하지 않는 코드를 삭제하지 마세요. 기껏해야, 주석정도 입니다.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrekhleb%2Fstate-of-the-art-shitcode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrekhleb%2Fstate-of-the-art-shitcode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrekhleb%2Fstate-of-the-art-shitcode/lists"}