Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

스타일 가이드 - 컴포넌트 이름의 단어 순서 정렬 #28

Open
Bogyie opened this issue Nov 9, 2022 · 0 comments
Open

스타일 가이드 - 컴포넌트 이름의 단어 순서 정렬 #28

Bogyie opened this issue Nov 9, 2022 · 0 comments
Assignees

Comments

@Bogyie
Copy link
Member

Bogyie commented Nov 9, 2022

### 컴포넌트 이름의 단어 순서 정렬 <sup data-p="b">매우 추천함</sup>
**Component names should start with the highest-level (often most general) words and end with descriptive modifying words.**
{% raw %}
<details>
<summary>
<h4>자세한 설명</h4>
</summary>
{% endraw %}
You may be wondering:
> "Why would we force component names to use less natural language?"
In natural English, adjectives and other descriptors do typically appear before the nouns, while exceptions require connector words. For example:
- Coffee _with_ milk
- Soup _of the_ day
- Visitor _to the_ museum
You can definitely include these connector words in component names if you'd like, but the order is still important.
Also note that **what's considered "highest-level" will be contextual to your app**. For example, imagine an app with a search form. It may include components like this one:
```
components/
|- ClearSearchButton.vue
|- ExcludeFromSearchInput.vue
|- LaunchOnStartupCheckbox.vue
|- RunSearchButton.vue
|- SearchInput.vue
|- TermsCheckbox.vue
```
As you might notice, it's quite difficult to see which components are specific to the search. Now let's rename the components according to the rule:
```
components/
|- SearchButtonClear.vue
|- SearchButtonRun.vue
|- SearchInputExcludeGlob.vue
|- SearchInputQuery.vue
|- SettingsCheckboxLaunchOnStartup.vue
|- SettingsCheckboxTerms.vue
```
Since editors typically organize files alphabetically, all the important relationships between components are now evident at a glance.
You might be tempted to solve this problem differently, nesting all the search components under a "search" directory, then all the settings components under a "settings" directory. We only recommend considering this approach in very large apps (e.g. 100+ components), for these reasons:
- It generally takes more time to navigate through nested sub-directories, than scrolling through a single `components` directory.
- Name conflicts (e.g. multiple `ButtonDelete.vue` components) make it more difficult to quickly navigate to a specific component in a code editor.
- Refactoring becomes more difficult, because find-and-replace often isn't sufficient to update relative references to a moved component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant