ミノ駆動本_読書py
      • 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
    # ミノ駆動本_読書py[1] みんなのメモ ###### tags: `ミノ駆動本` - このメモはWebに公開されています(HackMDチーム) - リンクを知っている人は見られます - HackMDにログインして編集できます ## このメモについて このメモは ミノ駆動本_読書py[1] のメモです https://pythonista-books.connpass.com/event/250340/ 読む範囲:3章 ## 読書会の流れ * 19:30〜20:00 自由参加のもくもく会(個人作業) - 事前に読む時間がとれなかった方はここで読んじゃいましょう(ざっとで大丈夫です) - 合わせて、この**HackMD**に話したいことを各自書いてください - ログインすれば書ける設定にしています - ここがわからん、ここはわかった お気軽に書き込んでみてください - HackMDの書き込みに投票し、みんなが気になるところをわいわい読み解いていきます * 20:00〜21:30 読書会本編(みんなでわいわい) * Discordでスライド共有して別途案内します * 20時の本編では、「わたしこれ気になる!」という話題に `:+1:` と書いて投票します。 * :+1: する上限はありません。気になる話題に全部 :+1: しちゃいましょう。ただし1つの話題には1個だけ:+1:でお願いします * 票数が多い話題から話していきます。 ## 以下、もくもく会ワークゾーン ### 感想、気付き - Pythonの言語仕様的な話が今回から出てき始めてドキドキワクワク - 1章2章より時間が短い気がしたw - ちょっとにっきーさんが書いたソースみていきたいっ! :+1: - ### Pythonでの実装例(nikkie案) https://github.com/ftnext/exile-of-the-wicked-py/blob/92a81a564ec01bba7d0e67da447848a86c83d2d5/chapter3/dataclass_version.py:+1: **ご意見大歓迎** - `@dataclass`で実装(`__eq__`など実装不要になるため) - Javaの標準ライブラリのCurrencyに相当するものはPythonの標準にもなさそうなので通貨単位は文字列で実装しました - 不変にするための`frozen=True`:+1: - 完全コンストラクタにするための`__post_init__`:+1: - +演算子サポートするために`__add__`を実装:+1: - Javaのコードのfinalに相当するものはPythonにはなさそう:+1::+1: Colabで開けるようにしてみています(この設定でみんな編集できる?) https://colab.research.google.com/drive/1uxm6W1O3dEsE9lqdOOl0tbZD98gjBxdd?usp=sharing 以下は各節で「これってどういうことなんだろう」「ここからこういう気付きがあった」などを書き出すゾーンです ### 3 クラス設計ーすべてにつながる設計の基盤ー #### 3.1 クラス単位で正常に動作するよう設計する - > クラス単体で正常動作するよう設計する - 身の回りのもの、大体クラス単位で正常に動作してる! - この例えかた、とても秀逸だなーって思いました。なんだろう、回路とか線とか何か色々組み合わさった姿で物が完成する?みたいな感じで捉えると、ふむふむとなりました - ガンプラでモジュール化を学んでみないか?(←趣旨が違う - 良いクラスの構成要素、インスタンス変数が無い場合とかってPyCharm(IDE)なんかだと、注意された?普通のメソッドとかに切り出せたような気がして、IDEを使うと自然と便利な形になるかな?なんて思いました - 「詳細な初期化や下準備をしないと使えないクラス」……うっ、頭がっっ!! - 「クラス単体で正常に動作する」を誤解すると、巨大クラス作成を誘発しそうだなと思いました。たとえば、ドライヤーやヘッドホンでいえば、中身はもっと細かいモジュール(≒クラス)に分かれているはずなので。:+1: #### 3.2 成熟したクラスへ成長させる設計術 3.2は項目が多いので、(3.2.4)のようにどこについてかを示していただけると進行上助かります - (3.2.1) これ、全然できてなかった気がしている・・・。最初に空白''や0みたいな値を入れるのをみて - (3.2.1) コンストラクタにException書くな!って怒られたけど、ガード節ならやってええのん? - ちなみになんで書くなって言われたとかは・・・? - 理由1:コンストラクタは「動作を書くところじゃない」だから。 - 他所の言語(C++やJava)の話ですが https://pasela.hatenablog.com/entry/20061129/1164947268 - 理由2:コンストラクタは、成功することが前提だから(だったかな?)。:+1: :+1: - (3.2.3) Pythonの不変(イミュータブル)とちょっと異なりそうな? タプルなら1回定義?代入?した後に再代入できなかったと思うけど、Strはイミュータブルなんだけどコピーしたオブジェクトに文字列を入れているので結果的にはミュータブルっぽく見えてるよね?って思っている - https://docs.python.org/ja/3/library/stdtypes.html#iterator-types - > **イミュータブルなシーケンスの結合は、常に新しいオブジェクトを返します。これは、結合の繰り返しでシーケンスを構築する実行時間コストがシーケンスの長さの合計の二次式になることを意味します。実行時間コストを線形にするには、代わりに以下のいずれかにしてください:** - (3.2.3, 3.2.5) `typing.Final`はJavaのfinalのように使えませんでした - https://peps.python.org/pep-0591/ - 関数の引数に使えない - (3.2.4) 「新しいオブジェクトに入れれば良い」は、実行時メモリが潤沢になった昨今だからできることだとも感じている - (3.2.6) もう、独自型を用意しないと生きていけませんっ!! - mypy + 独自型でかなり開発経験(DX)よさそうですよね。:+1: - ただ私が出会ったPython使いはプリミティブ型好きな方多く、mypy + プリミティブ型になりがち(みんなもっと独自型使おう!!) - (3.2.x) - (3.2.x) - #### 3.3 悪魔退治の効果を検証する - setter/getterがカプセル化じゃないんだっ!これが本当のカプセル化なんだっ!! - 未だに、setter/getterで値を外部に公開することが許される理由が判らない - public で公開が駄目なのは、納得している - メモリを直接参照できないってことが重要なのかも? - めっちゃ初歩的だけどカプセル化って、必要な手続き(メソッド)のみを外部へ公開すること...なんですね。:+1: :+1::+1: - 外部へ公開すること... となると、なんだろう、パブリックなメソッドが1つ、インスタンスから呼び出して実行される物があって、そのほか公開しないものはプライベートにしておく、で良いのかな(うまくいえるような言えないような・コードが書けそうで書けなかったw):+1: - 良いと思います! - #### 3.4プログラム構造の問題解決に役立つ設計パターン - 値オブジェクトとしての設計可能な値、概念をOSSのソースで何か表現しているものはないだろうか(サンプルコードが見たくなってきた) - なんとなく、概念がわかってもそれをどうコードに落とし込むか分からないな?理解が及んでいない?と思っていたので・・・ とここまでで書いていたら、リスト3.19にRuby版Moneyクラスが書かれているではないか!!  - あとはなんだろう、Pythonで「そこまでやるのか?」みたいなところまで踏み込んで話が出来ても良いのかも?(ちょっとうまく言えないけど) 一応、言語の機能として出来るよ、ただし複雑になるよ・・・ みたいな話だと、無理にしなくても良いのかなと思ったりラジバンダリ - Pythonかどうか、ではなく開発の状況や要件次第という感じではないでしょうか? 技術レベルもバラバラな大人数の開発であれば、違反するような記述をできないようにしておく価値はとても高いと思います。この本では、性悪説を前提にして、比較的大きなシステム開発を大人数で取り組むことを想定している気がします。:+1: :+1: - コラムでRubyやJavaScriptのfreezeが紹介されています:+1::+1: - Pythonでも@dataclass(frozen=True)はあります - ところが`object.__setattr__`があり、frozen=Trueでも属性に代入された値を変えられます - 聞きたい方いたらもっと話します - 気になる! - 気になる!2号ッ

    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