Skip to Content
ロバストPython ―クリーンで保守しやすいコードを書く
book

ロバストPython ―クリーンで保守しやすいコードを書く

by Patrick Viafore, 鈴木 駿, 長尾 高弘
March 2023
Intermediate to advanced
384 pages
5h 30m
Japanese
O'Reilly Japan, Inc.
Content preview from ロバストPython ―クリーンで保守しやすいコードを書く

7章実践的な型チェックの導入

開発者はいつの日か完全なグリーンフィールドプロジェクトで仕事をすることを夢見る。グリーンフィールドプロジェクトとは、完全な新規プロジェクトのことで全くの白紙状態からアーキテクチャ、設計、モジュール構造を決定できるプロジェクトだ。しかし、ほとんどのプロジェクトはあっという間にブラウンフィールドになる。つまり、レガシーコードだ。こういったプロジェクトには歴史の重みがある。アーキテクチャと設計の大部分はすでに固まっている。全面的な変更を加えると、今ここにいるユーザに影響を及ぼす。ブラウンフィールドという言葉には大きな泥の塊を相手にするという語感があり、悪く捉えられることが多い。

しかし、すべてのブラウンフィールドプロジェクトが辛い仕事になるわけではない。マイケル・フェザーズは、次のように言っている。

よく保守されたシステムは、コードの書き換え方を理解するのに時間がかかる場合があるが、大抵、一度理解すれば変更は簡単になりシステムをより快適に感じられる。レガシーシステムでは、どうすべきかを理解するのに長い時間がかかり、変更も困難だ。†1

[†1] Michael C. Feathers. Working Effectively with Legacy Code. Pearson, 2013. 邦訳は『レガシーコード改善ガイド』(翔泳社、2009年)。

フェザーズは、レガシーコードを「テストなしのコード」と定義するが、私は、レガシーコードを「最初に書いた開発者と議論できなくなったコード」と定義する。最初に書いた開発者と対話ができないなら、コードベースが自ら記述する振る舞いに頼るしかない。コードベースが作者の意図を明確に伝えるならば、それは保守されたシステムであり簡単に仕事に取りかかれる。全体を理解するために少し時間がかかるが、理解すれば機能を追加してシステムを発展させていける。しかし、コードベースが理解しにくければ、苦しい展開が待ち受ける。そのコードは保守不能である。ロバストネスが至上命令となるのはそのためだ。ロバストコードを書けば、コードが保守しやすくなるためグリーンフィールドからブラウンフィールドへの遷移に伴う問題が軽減される。 ...

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

Pythonからはじめるアルゴリズムトレード ―自動売買の基礎と機械学習の本格導入に向けたPythonプログラミング

Pythonからはじめるアルゴリズムトレード ―自動売買の基礎と機械学習の本格導入に向けたPythonプログラミング

Yves Hilpisch, 村上 振一郎
サイトリライアビリティワークブック ―SREの実践方法

サイトリライアビリティワークブック ―SREの実践方法

Betsy Beyer, Niall Richard Murphy, David K. Rensin, Kent Kawahara, Stephen Thorne, 澤田 武男, 関根 達夫, 細川 一茂, 矢吹 大輔, 玉川 竜司
スクラム実践者が知るべき97のこと

スクラム実践者が知るべき97のこと

Gunther Verheyen, 吉羽 龍太郎, 原田 騎郎, 永瀬 美穂

Publisher Resources

ISBN: 9784814400171Other