Skip to Content
Tidy First? ―個人で実践する経験主義的ソフトウェア設計
book

Tidy First? ―個人で実践する経験主義的ソフトウェア設計

by Kent Beck, 吉羽 龍太郎, 永瀬 美穂, 細澤 あゆみ
December 2024
Beginner to intermediate
164 pages
1h 15m
Japanese
O'Reilly Japan, Inc.
Content preview from Tidy First? ―個人で実践する経験主義的ソフトウェア設計

31章結合 vs 分離

 

なぜすべてを分離しないのか? そもそも、なぜ結合がそこにあるのだろうか?

結合は、夜のレゴのパーツのように、それを踏むまで明らかでないことが多い。ある振る舞いを変更しようとして、「ああ。これを変更するなら、あれもそれも変更しなければいけない」と気づく。もしくは、さらにひどい場合には、変更を本番環境に投入して、何かを壊し、そこで「ああ。あれもそれも変更しなければいけなかったのか」と気づく。無意識の憶測にあなたは気づいていないのだ。

ディスカウントキャッシュフローでは、多少の結合を考慮に入れている。たとえば、ある振る舞いを実装するのに、すばやくできるが結合がある方法と、時間とお金はかかるが分離している方法があったとする。開発当時は、経済的に正しい判断をして、結合のあるやり方で実装したのではないだろうか。つまり収入を先にして、支出をあとにしたのだ。そして、今が支出のときというわけだ。

システムに結合がある別の合理的な理由は、それがまさに今まで問題でなかったからだ。山頂の巨石が、今まさに村へ向けて転がり落ちそうになっていて、それを受けて判断をしたのだ。「国際化が必要になるなんて思ってもいなかった!」 人は、自分がするはめになるまで気づかないものだ。

結合がある最後の理由は、多少の結合は不可避だからだ。申し訳ないが、これについては「自信を持って主張する」以上の根拠はない。根拠については今後取り組むつもりだ。

結合がある理由はあまり重要ではない。あなたは今、結合のコストを払うか、分離のコストを払うかの判断に直面している。「先に整頓するか?」という問いはこの判断を小さくしたものだ(ただし結合がコードの乱雑さの要因になっているのは一部にすぎないが)。

具体例を見てみよう。通信プロトコルだ。シンプルな実装方法は、送信用の関数と受信用の関数を作ることだ。 ...

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

Tidy First?

Tidy First?

Kent Beck
Fluent React

Fluent React

Tejas Kumar
Command-Line Rust

Command-Line Rust

Ken Youens-Clark

Publisher Resources

ISBN: 9784814400911Publisher Website