Skip to Content
Pythonによるアーキテクチャパターン
book

Pythonによるアーキテクチャパターン

by Harry Percival, Bob Gregory
March 2025
Intermediate to advanced
304 pages
4h 33m
Japanese
O'Reilly Media, Inc.
Content preview from Pythonによるアーキテクチャパターン

第3章. 束の間の幕間カップリングと抽象化について

この作品はAIを使って翻訳されている。ご意見、ご感想をお待ちしている:translation-feedback@oreilly.com

読者の皆さん、抽象化について少し話を逸らすことをお許し願いたい。 これまで抽象化については何度も話してきた。 例えば、Repositoryパターンは永続的なストレージに対する抽象化である。しかし、良い抽象化とは何だろうか? 私たちは抽象化に何を求めているのだろうか? そしてそれらはテストとどのように関係しているのだろうか?

チップ

この章のコードはGitHubのchapter_03_abstractionsブランチにある:

git clone https://github.com/cosmicpython/code.git
git checkout chapter_03_abstractions

派手なパターンに隠された本書の重要なテーマは、単純な抽象化を使って厄介な詳細を隠せるということだ。 楽しみながらコードを書いているとき、あるいは型にはまったコードを書いているとき、1 私たちは自由にアイデアと戯れ、物事を打ち出し、積極的にリファクタリングすることができる。しかし大規模なシステムでは、システム内の他の場所で下された決定によって制約を受けることになる。

コンポーネントBが破壊されることを恐れてコンポーネントAを変更できない場合、コンポーネント、結合していると言う。各コンポーネントが他のコンポーネントをサポートし、すべてのコンポーネントが時計の歯車のように所定の位置に収まっている。専門用語では、結合された要素の間に高い結束力があるとき、これが機能すると言う。

グローバルに見れば、カップリングは厄介なものだ。 、コードを変更するリスクとコストを増大させる。時には、変更をまったく加えることができないと感じるほどだ。アプリケーションが大きくなるにつれて、結合力のない要素間の結合を防ぐことができなければ、結合は超直線的に増加し、システムを効果的に変更することができなくなる。

(図3-1)システム内の結合の度合いは、詳細を抽象化することで減らすことができる(図3-2)。

apwp 0301
図3-1. たくさんのカップリング
[ditaa,apwp_0301]
+--------+      +--------+
| System | ---> | System |
|   A    | ---> |   B    |
|        | ---> |        |
|        | ---> |        |
|        | ---> |        |
+--------+      +--------+
apwp 0302
図3-2. カップリングを減らす
[ditaa,apwp_0302] +--------+ +--------+ | System | /-------------\ | System | | A | ---> | | ---> | B | | | ---> | Abstraction | ---> | | | | | | ---> | | | | \-------------/ ...
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

技術リーダーシップのための14のヒント

技術リーダーシップのための14のヒント

島田 浩二
Kubernetesで実践するクラウドネイティブDevOps

Kubernetesで実践するクラウドネイティブDevOps

John Arundel, Justin Domingus, 須田 一輝, 渡邉 了介
AWS上のシステム設計

AWS上のシステム設計

Jayanth Kumar, Mandeep Singh

Publisher Resources

ISBN: 9798341624863