1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

「良いコード/悪いコードで学ぶ設計入門」を読んで、設計の視点が変わった話

Posted at

💡 「動くコード」じゃなく、「成長するコード」を書こう!

「とりあえず動けばOK!」で書いたコードが、数ヶ月後に自分を苦しめた経験、ありませんか?

  • 「この関数、どこで使われてるんだ…?」
  • 「仕様変更のたびに影響範囲が読めない…」
  • 「チームで開発すると、コードの書き方がバラバラ…」

そんな悩みを解決してくれるのが、📖 「改訂新版 良いコード/悪いコードで学ぶ設計入門」 です!


👀 本書のポイント

「悪いコード vs 良いコード」で具体的に学べる
リファクタリングの実践的なテクニックが満載
現場の実例を元にした解説で、すぐに使える

例えば…

悪いコード

def calc_price(quantity, item_type):
    if item_type == "A":
        return quantity * 100
    elif item_type == "B":
        return quantity * 200
    elif item_type == "C":
        return quantity * 300
    else:
        return 0

条件分岐が増えるたびにメンテが大変! 😱

良いコード

class Item:
    def __init__(self, price):
        self.price = price

    def calc_price(self, quantity):
        return self.price * quantity

items = {"A": Item(100), "B": Item(200), "C": Item(300)}
def calc_price(quantity, item_type):
    return items.get(item_type, Item(0)).calc_price(quantity)

オブジェクト指向を活かして、拡張しやすく! 🎉

こんな感じで 「ダメなコード → 改善方法」 を具体的に学べるので、実務ですぐに活かせます!


🛠 こんな人にオススメ!

  • コードのメンテがつらいと感じているエンジニア
  • 設計についてしっかり学びたい中級者エンジニア
  • リファクタリングのコツを知りたい人

「設計を学ぶ」とは、「未来の自分を助けること」 です。
より良いコードを書きたいなら、この本を読んでおくべき! 🚀

📖 Amazonリンク(単行本ソフトカバー)→ 改訂新版 良いコード/悪いコードで学ぶ設計入門

📖 Amazonリンク(Kindle版) → 改訂新版 良いコード/悪いコードで学ぶ設計入門

#良いコード悪いコード #設計入門 #リファクタリング #エンジニア #コードの品質

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?