Skip to Content
Head Firstデザインパターン 第2版 ―頭とからだで覚えるデザインパターンの基本
book

Head Firstデザインパターン 第2版 ―頭とからだで覚えるデザインパターンの基本

by Eric Freeman, Elisabeth Robson, 佐藤 直生, 木下 哲也
June 2022
Beginner to intermediate
672 pages
17h 23m
Japanese
O'Reilly Japan, Inc.
Content preview from Head Firstデザインパターン 第2版 ―頭とからだで覚えるデザインパターンの基本
師匠と弟子
師匠:最後に会ってからしばらく時間が経ったな。継承について深
く考えたか?
弟子:はい、師匠。継承は強力ですが、必ずしも最も柔軟な設計や
保守性のある設計につながるわけではないことを学びました。
師匠:よろしい、いくらか進歩したな。それでは、継承を使用しない場合、どのよう
に再利用を実現するか言うてみよ。
弟子:師匠、私はコンポジションと委譲を使って実行時に振る舞いを「継承」する方
法があることを学びました。
師匠:続けよ。
弟子:サブクラス化で振る舞いを継承すると、その振る舞いはコンパイル時に静的に
設定されます。さらに、すべてのサブクラスが同じ振る舞いを継承しなければいけま
せん。しかし、コンポジションを使ってオブジェクトの振る舞いを拡張すると、振る
舞いの拡張を実行時に動的に行うことができます。
師匠:よくできたな。コンポジションの威力を理解し始めたようだな。
弟子:はい、コンポジションを使うと、スーパークラスの設計者が思いつかないよう
な責務を含む、複数の新しい責務をオブジェクトに追加できます。また、コードをい
じる必要がありません!
師匠:コードの保守に関するコンポジションの効果については何を学んだか?
弟子:えー、それこそ私が目指していたことです。動的にオブジェクトを構成するこ
とで、既存コードを変更するのではなく新しいコードを書いて新機能を追加できま
す。既存コードを変更しないので、既存コードにバグを発生させたり予期せぬ副作用
を引き起こしたりする可能性がかなり減少します。
師匠:よくできたな。今日のところは十分だ。この話題についてさらに理解を深める ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

マッピングエクスペリエンス ―カスタマージャーニー、サービスブループリント、その他ダイアグラムから価値を創る

マッピングエクスペリエンス ―カスタマージャーニー、サービスブループリント、その他ダイアグラムから価値を創る

James Kalbach, 武舎 広幸, 武舎 るみ

Publisher Resources

ISBN: 9784873119762Other