O’REILLY Learning「Good Code, Bad Code」3 Other engineers and code contracts

https://learning.oreilly.com/library/view/good-code-bad/9781617298936/

日本語翻訳版は秀和システムから発売

3 Other engineers and code contracts

This chapter covers
・How other engineers will interact with our code
・Code contracts and small print in code contracts
・How minimizing small print can help prevent misuse and surprises
・If we can’t avoid small print, how checks and assertions can be used to enforce it

コードを書くときには、次の3つのことを考慮すると便利。
・自分にとっては当たり前のことでも、他の人にとっては当たり前でない。
・他のエンジニアは、うっかりあなたのコードを壊そうとします。
・やがて、自分のコードのことは忘れてしまう。

他のエンジニアがコードの一部を正しく使用することを確実にするために小文字に頼るのではなく、間違ったことをすることを不可能にする方が良い。

「〜不可能にする方が良い。」めちゃ大事です!!

memoO'REILLY Learning

Posted by shi-n