Kota Kanazawa
    • Create new note
    • Create a note from template
      • 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
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me 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
    • Save as template
    • 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 Create Help
Create Create new note Create a note from template
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
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me 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
    # 良いコード/悪いコードで学ぶ設計入門 ## 第9章 P.179~201 - 任意参加 - ファシリテーター: kanazawa ### 話す・書く順番決めルーレット in Ruby ```ruby ['kawasaki','hsu', 'chen', 'teruya', 'kanazawa', 'okura', 'kanno'].shuffle.each { |v| puts ">[name=#{v}]\n\n" } ``` in JavaScript ```javascript const l = ['kawasaki', 'hsu', 'chen', 'teruya', 'kanazawa', 'okura', 'kanno'] l[Math.floor(Math.random()*l.length)] ``` ### ファシリテーター決め方 - `%w(hsu chen teruya kanazawa okura kanno)`の順番でやっていく ### 参加者がやること - 事前に決められた章を読む - 学んだことやわからなかったことを書き込む(任意) 当日 - 最初に感想や質問を書く時間を設ける(10分) - 時間枠 60分 - 延長枠 30分 ### 勉強会時にやること 各自学びや気付き、疑問を発表していく ファシリテーターがよしなに議論を進める 終了前に勉強会を振り返る?(KPTなどで)← 60分のときに仮締め ## 各自が書き込む場所 >[name=kanno] - デッドコード or 到達不能コード 可読性の低下 なぜ実行されないようなコードがあるのか読み手を混乱させる 前にExercise周りのコードに到達しないelse節があって大倉さんと削除した記憶 - マジックナンバー 定数として定義しよう   定数が複数ある時ハッシュにするかで悩むけどコンテキストによりそう?? - 文字列型執着  そんなことする人いる?!と思いました - null ruby の&.もアンチパターンですか…?? - サンプルコードのコピペ  鵜呑みにすると粗悪なロジックが誕生する ~~昔めちゃくちゃやっていたけど~~もうやらないな… -  銀の弾丸    bestはない、常にbetterを目指す >[name=teruya] > デッドコード p180 に載っているようなのってIDEで検知可能なんですかね…? > 文字列型執着(p184) そんなものは見たことがない > nullを返さない、渡さない(p189) よほどのことがない限り null: false をつけたい > 例外の握り潰し(p191) SIer時代にたまに見たw >[name=okura] ### 9.1 デッドコード デッドコードはRuboCopでも検出してくれるが、完全ではない。 https://docs.rubocop.org/rubocop/1.36/cops_lint.html#lintunreachablecode ### 9.2 YAGNI原則 重要だけど、見極めが難しい。後日の拡張に備えた設計は重要だけど、やりすぎると理解困難になりがち。 ### 9.3 マジックナンバー 定数にしよう! ### 9.4 文字列型執着 見たことない… ### 9.5 グローバル変数 Rubyはトップレベルの定数がグローバルなので注意。 ### 9.6 null問題 基本的に`nil`に頼りすぎない設計は重要。ただ、全ての箇所で`EMPTY`的なものを返すようにすると煩雑な感じになるので、バランス感が重要だと思う。 ### 9.7 例外の握り潰し 例がやばすぎて笑う。 ちなみに、 https://ja.wikipedia.org/wiki/UNIX%E5%93%B2%E5%AD%A6#%E3%83%AC%E3%82%A4%E3%83%A2%E3%83%B3%E3%83%89:[…]F%E3%83%B3%E3%82%B0%E3%81%AE%E6%8A%80%E6%B3%95 にある「修復のルール」がだいたい同じことを言っている(つまり40年間くらい受け継がれてきた考え方)。 ### 9.8 設計秩序を破壊するメタプログラミング 動的型付け言語であるRubyでは静的型付け言語とはちょっと考え方が違う。メソッドの呼び出しとかはIDEの支援を受けられないのでgrepする必要があって、そうなると動的に定義されたメソッドでも適切にコメントされていれば発見できる。 ただ、Deviseでの`current_user`みたいに動的に定義されたメソッドの発見が困難なケースもあるので難しい。 ただし、`instance_variable_set`とかは濫用厳禁。 ### 9.9 技術駆動パッケージング 何を言っているのかよくわからない。 MVCは安定した構造であり、アプリケーションの寿命の中で変化しない。一方、ドメインの構造は変化する。ドメインの構造が変化したらディレクトリ構造を変更するのか?あるいは複数ドメインから参照されるファイルはどこに置くのか? > ファイル単位で低凝集になってしまう これも謎。これまで触れてきたシステムでファイル単位の結合や凝集について考えたこともないし考えている人を見たこともない。そもそも、コードの中でクラス名が明示されているのだからそのクラス名で検索すれば関連ファイルは一瞬で見つかる。 この節は多分本書で一番意味不明な箇所、読み飛ばすべし。 ### 9.10 サンプルコードのコピペ ぶっちゃけ、コピペ元を書いておいてくれさえすれば、後から意味が理解できるのでそれで十分かも。 ### 9.11 銀の弾丸 https://ja.wikipedia.org/wiki/%E9%8A%80%E3%81%AE%E5%BC%BE%E3%81%AA%E3%81%A9%E3%81%AA%E3%81%84 名著なのでぜひ読んでみてほしい(ちなみに1986年の論文らしいので、こちらも40年近く昔の話だけど、今でも通じる)。 >[name=kanazawa] - YAGNI - Rewrites教師の給与明細の話 - マジックナンバー - キャタル入った頃めちゃくちゃ注意受けた - グローバル変数 - 今まで意識して開発したことない(むしろいつ使うのか) - null問題 - Rubyならnil問題 - ぼっち演算子(`&.`)多用問題 - 例外の握りつぶし - 見たことない。こんなの書く人ほんとにいるの? - メタプログラミング - プロダクションコードではあまり見かけない - gemで使われることが多い印象 - サンプルコードのコピペ - コピペ自体が悪いのではなく、何もわかってない状態でコピペをするのがダメ - 銀の弾丸 - 良い言葉「設計にbestはない。常にbetterを目指す」 - 70〜80点くらいで出して早めにフィードバックもらう ## 振り返り > [name=teruya] たまに「そうはならんやろ」が出てくるのが興味深い >[name=okura] この章は癖が強い。「技術駆動パッケージング」だけは本当にわからん。 >[name=kanazawa] - 今日はサクサク読めた > [name=kanno] - rubyのメタプロ系メソッドの名前が長い理由がおもしろかった ## 終了後ファシリテーターがやること - 次回のファシリテーターを決める - 大倉さん - 読む範囲を決める - 10章 - サクサク読んでいこうぜ!

    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