NUTMEG
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 20231220_実務を通じて実感した命名規則 (例:20210901_LT会を開催しました) ###### tags: `ブログ記事` - [ ] 公開(ブログ公開担当者がいじるやつ) 太字斜体で書いてある内容を埋めて行ってください. 文章,画像は太字斜体の下の行に入れてください. 最初に書く時はREADMEを読んだら読むといいと思います. <br> ## 表示されない情報 ***書いた人の名前(自己紹介文と同じ名前)*** { 佐藤昌信 } ***記事の簡単な説明(検索した時にタイトルの下に出てくる文章)*** { 命名規則の基本的な使い分けについて } <br> ## 表示される部分 ***サムネイル画像*** { ![のぶ](https://hackmd.io/_uploads/B1zIgHewp.jpg) } ***カテゴリ*** 以下の中から該当しそうなカテゴリを選択してください ※一つだけ選択してください - [ ] 対外活動 - [ ] 活動の様子 - [ ] メンバーの趣味 - [x] NUTMEG Advent Calendar 2023 ***タグ*** 以下の中から該当しそうなカテゴリを選択してください.当てはまる物がない場合は適宜追加してください. 言語 - [ ] HTML - [ ] CSS - [ ] Python - [ ] Go - [ ] Ruby - [ ] JavaScript - [ ] TypeScript - [ ] Dart - [ ] Rust - [ ] Kotlin - [ ] Swift フレームワーク・ライブラリ - [ ] Ruby on rails - [ ] Vue.js - [ ] Nuxt.js - [ ] React.js - [ ] Next.js - [ ] Gin - [ ] Flluter ツール - [ ] GitHub - [ ] ターミナル - [ ] WSL - [ ] Ubuntu - [ ] Docker - [ ] Raspberry Pi - [ ] Figma 分野 - [x] チームづくり - [ ] フロントエンド - [ ] バックエンド - [ ] インフラ - [ ] Web-design - [ ] API関係 --- ***以下に本文を記載してください*** ## はじめに 普段プログラムを書く際に,命名規則は意識していますか? 個人開発の時には,あまり意識なくても大丈夫なものですが,チーム開発において命名規則を決めておくことはとても重要です. レビューなどでプログラムを読んでもらう際に,命名規則が適当だとプログラムを理解するのに時間がかかってしまい,作業効率が落ちてしまいます. 自分は実務訓練の際に,この命名規則が少し適当だったため,レビューにかなり時間がかかりました. そのため,本ページでは,開発における命名規則について触れていこうと思います. ## 命名規則 さっそく命名規則について説明していきます. 多くのプログラムで使用されている命名規則は以下の4つです. - キャメルケース - パスカルケース - スネークケース - ケバブケース ### キャメルケース キャメルケースとは`camelCase`みたいな感じに複数の単語を一つの綴りにして,接続する2つ目以降の単語の最初の文字を大文字で書くスタイルです. `camel`とはラクダを意味しますが,単語の先頭が大文字になってラクダのコブのように見えることからキャメルケースと呼ばれています. キャメルケースは,プログラムにおいて,関数名や変数名に使われます. ### パスカルケース パスカルケースとは`PascalCase`のように各単語の先頭を大文字で書くスタイルです.プログラミング言語のパスカルで使用されていたことが由来みたいです.パスカルケースはクラス名やモジュール名など,関数よりのさらに大きいくくりの場所の命名に使われています. ### スネークケース スネークケースとは`snake_case`のように各単語を`_`(アンダースコア)でつなげて書くスタイルです.スネークケースはキャメルケースと同様に関数名や変数名に使われています. なお,キャメルケースとスネークケースの使い分けは特に厳しく決まっているわけではないため,プロダクトごとに使い分けましょう. ### ケバブケース ケバブケースとは`kebab-case`のように各単語を`-`(ハイフン)でつなげて書くスタイルです.ケバブケースは`-`を使っている関係上,ファイル名に使われます. ## 名前の付け方 前の章では,命名規則について説明しました.しかし,命名規則を知っただけでは,読みやすいコードをかけるようにはなりません. 命名規則を知ったうえで,下記の項目での名前の付け方を気を付けることでさらに読みやすくなります. - クラス名 - 関数名 - 変数名 ### クラス名 クラス名やモジュール名を決めるにあたって,意識することは「**クラス名は名詞にする**」ということです. 例えば「ユーザを登録するクラス」を作るとしましょう.「ユーザを登録するクラス」を安直に翻訳して`RegisterUsersClass`みたいな感じに命名してはいけません.これだと`UsersClass`を登録するみたいな意味になってしまいます. そのため,一度「ユーザを登録する」という動詞から「ユーザ登録」という名詞に置きなおしてから翻訳しましょう.そうすると`UsersRegistrationClass`となり,他人が読みやすい形になります. ### 関数名 関数名やメソッド名では,基本的に`動詞+名詞`の形で名前を付ける場合が多いです.`動詞+名詞`の形以外にも`is(has)+名詞`などの形もあります.関数名の決め方については数が多いため,詳細は下記のリンクを参照してください. [プログラムにおいて命名がうまくいくコツ](https://aimstogeek.hatenablog.com/entry/2023/01/17/121609) また,関数名に動詞を使用しますが,幅広い意味を持つ動詞はあまり推奨されていません.例えば,`get`や`check`などです. `get`は何かの変数の値を取得する関数なのかなと予想はできますが,web業界だと外部のAPIから情報を取得するなど,同じプログラム内で意味が少し変わってしまったりしてしまいます. また,`check`だと変数の値を確認する関数だと予想はできます.しかし,戻り値がbooleanなのか,それともintや変数特有の型なのか判断ができません. 以上のことなどから,幅広い意味をもつ動詞をなるべく使用しないことが読みやすいコードを書くことにつながります. こちらも詳細は,以下のリンクを参照してください. [プログラムの命名で使う/使わない単語](https://web-camp.io/magazine/archives/117113) ### 変数名 変数名は基本的に`名詞`で名前を付ける場合が多いです.もちろん名詞を修飾する形も多く存在します.変数名も関数名と同様に決め方が多いため,関数名の章で紹介したサイトを参照してもらうとより理解ができると思います. ## 最後に さて,これまで命名規則などについて説明してきました. サークルなどでは,コードの内部を詳細までレビューをしたりしますが,会社ではレビューにあまり時間をされられないため,クラス名(モジュール名)や関数名(メソッド名)だけをみて,あらかた判断したりしている感じです.(動作の確認は単体検査などでしている) そのため,クラス名(モジュール名)や関数名(メソッド名)からどんな操作がされるかを判断できるようなコードを書くことで,他人が自分のコードを短い時間で理解することができます. また,他人に理解しやすいコードを書くために多くの英単語を知っておくことで,命名に時間をかけずに済みます.英語の勉強は継続して頑張りましょう. 実務訓練が始まって間もないころ,職場の指導職員からある本を借りて読みました.その本は,大学でも読んだことがある本でした. **そう,「リーダブルコード」です!** 今後もプログラムとの関りがあると思っているなら,一度は読むことをお勧めします.実務訓練の職場でも多くの人が読んだことがあるみたいです. [リーダブルコード](https://www.amazon.co.jp/%E3%83%AA%E3%83%BC%E3%83%80%E3%83%96%E3%83%AB%E3%82%B3%E3%83%BC%E3%83%89-%E2%80%95%E3%82%88%E3%82%8A%E8%89%AF%E3%81%84%E3%82%B3%E3%83%BC%E3%83%89%E3%82%92%E6%9B%B8%E3%81%8F%E3%81%9F%E3%82%81%E3%81%AE%E3%82%B7%E3%83%B3%E3%83%97%E3%83%AB%E3%81%A7%E5%AE%9F%E8%B7%B5%E7%9A%84%E3%81%AA%E3%83%86%E3%82%AF%E3%83%8B%E3%83%83%E3%82%AF-Theory-practice-Boswell/dp/4873115655/ref=sr_1_1?__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A&keywords=%E3%83%AA%E3%83%BC%E3%83%80%E3%83%96%E3%83%AB%E3%82%B3%E3%83%BC%E3%83%89&qid=1702738236&sr=8-1) これからも楽しみながら,開発をやっていきましょう!

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully