Web制作、Web開発の歩き方

分かりやすいコードの書き方

第10話:これからのコーディング

(最終更新日:2025.5.03)


分かりやすいコード

この記事は5分で読めます!
(絵が小さい場合はスマホを横に)

これからのコーディング

ここまで、コードの可読性・保守性・拡張性を高めるための具体的なテクニックと設計原則を9回にわたって紹介してきた。 最終回となる今回は、これからの時代に向けてのコーディングスタイルの変化や、分かりやすいコードを書くために、 私たちが今からできることを振り返る。特にAI活用などは、今後に必須のテクニックだ。 ただし、AIだけではできないことも多くある。その本質的なポイントは人間がおさえる必要がある。 今も昔も変わらない設計のポイントだ。




1.今後のコードの書き方のトレンド

今後のコードの書き方としては「記述量を減らすよりも、読みやすさ・明確さを優先する」 「意図をよりよく伝える」「テストファースト」「データ駆動設計」「OCP原則の遵守」などが当たり前になりつつある。 加えて、フレームワークの使用、型安全を意識した構造的設計も広がってきている。

2.AI(GitHub Copilotなど)との共存

近年ChatGPTのような汎用的な対話型AIの登場により、コーディングにおいてもAIの存在は無視できない。 これらのAIの登場により、コードの自動補完やテンプレート化が更に進んできている。 GitHub CopilotやAPIを通じたIDEと各種AIの連携は不可欠で、これなしには生産的なコーディングが出来ないと言っても過言ではない。

しかしながら、AIは「開発の意図」や「設計の背景」までは書いてくれない。 そのため、これからの開発者は「AIが出したコードを読みやすく直し、意味を添える」ことが求められる。 コメント・命名・分割の判断など、人間の知性が必要な領域は今後ますます重要になる。 加えて、使う人たちの目的に沿ったルール作り、それを反映したコーディング能力が、今後は更にウェイトが大きくなるだろう。

ヒアリング、合意形成が大事

3.実践的なガイドラインの再確認

分かりやすいコードを書くために必要なことを再度下記にまとめよう。 以下の6項目だ。

  • 一貫した命名ルールを持つ
  • 1関数1責務を徹底する
  • ifを減らして構造で表現する
  • 早めに関数分割する(「あとで直そう」は直さない)
  • ログ・コメントに「なぜ」を書く
  • 変更が入りそうな箇所はデータ化・抽象化しておく

実践的なコーディングのガイドラインは以下の通りになる。 上記の6項目と内容は同じだが、作業ごとに分けている。 非常に重要なことなので、これらの項目は遵守できるようにしよう。

項目 ポイント
命名 意図・対象・役割を明示する
関数 責任を限定し、副作用をなくす
コメント なぜそうしたかを書く。やったことはコードが語る
テスト 小さく、再現性があり、早く壊れるテストを書く
設計 変更を前提に。分離・抽象・レイヤーで守る

4.あなたにとって「良いコード」とは

「読みやすいコード」とは、書き手の視点だけでなく、将来読む誰かのために書かれたコードだ。 その「誰か」は、未来のあなた自身かもしれない。 このシリーズを通じて、少しでも貴方にとっての「良いコードとは何か?」という問いが芽生えたなら、それが最大の成果だ。

  • 読み手はどこで迷いそうか?
  • 読み返したときに「なぜこの実装なのか」思い出せるか?
  • チームの仲間が、同じ判断を下せるか?

このような問いを持ちながらコードを書こう

5.最後に

分かりやすいコードを書くことは、技術的なスキルであると同時に、読者(未来の開発者)への思いやりだ。 AIの補助が進んでも、設計、説明、判断、意図の共有は人間にしかできない。 それこそが、これからの開発者に求められる力だ。 あなたが書くコードが、チームを助け、未来の自分を助けるものでありますように。 「良いコード」とは何かを、ぜひあなた自身の言葉で考えてみよう。

▼参考図書、サイト

 「リーダブルコード」 Dustin Boswell、Trevor Foucher 著、角 征典 訳 オライリー

Writing Readable Code Episode 10: The Future of Coding (Last Updated: 2025.5.03) Readable Code This article takes 5 minutes to read! (If the image is small, try rotating your phone) The Future of Coding Over the past 9 episodes, we've covered concrete techniques and design principles to improve readability, maintainability, and extensibility in code. In this final episode, we'll look at how coding styles are changing and what we can do now to write more readable code for the future. Especially, utilizing AI is becoming a crucial skill. However, there are still many things that AI alone cannot do. Developers must still understand the fundamental principles of good design—something that hasn’t changed over time. [Contents] Trends in Future Coding Styles Coexisting with AI (e.g., GitHub Copilot) Revisiting Practical Guidelines What Does “Good Code” Mean to You? Final Thoughts 1. Trends in Future Coding Styles Coding trends are shifting toward prioritizing readability and clarity over simply reducing lines of code. Emphasizing intent, test-first approaches, data-driven design, and adherence to the OCP principle are becoming standard. Structured design with frameworks and type safety is also spreading. 2. Coexisting with AI (e.g., GitHub Copilot) The emergence of general-purpose conversational AIs like ChatGPT has made AI an integral part of the coding process. Code auto-completion and templating have advanced significantly. Tools like GitHub Copilot and IDE integrations with APIs and AI are now essential to productive development. However, AI cannot express the "intent" or "context" behind development. Therefore, future developers must refine the code generated by AI, adding clarity and meaning. Human judgment is essential for naming, commenting, and code structure decisions. Moreover, developers will increasingly need to define rules aligned with their team's goals and reflect those in their code. Hearing and consensus building are vital 3. Revisiting Practical Guidelines Let’s review what’s essential for writing readable code. Here are six key points: Maintain consistent naming rules Ensure each function has a single responsibility Reduce `if` statements and express logic structurally Split functions early (“I'll fix it later” usually doesn’t happen) Use logs and comments to explain “why” Abstract and data-drive parts that are likely to change The following table summarizes practical coding guidelines, divided by task. These mirror the six points above but are grouped by topic. These are critical and should always be followed. Category Key Point Naming Make the intent, target, and role explicit Functions Limit responsibilities and avoid side effects Comments Explain why; what you did is clear from the code Tests Write small, reproducible, and easily breakable tests Design Plan for change; protect with separation, abstraction, and layering 4. What Does “Good Code” Mean to You? “Readable code” is not just for the author—it’s written for future readers. And that reader could be you in the future. If this series has helped you start thinking about what “good code” means to you, then that’s the biggest takeaway. Where might the reader get confused? Can you remember “why this implementation” when you look back later? Can your teammates make the same decision based on your code? Write your code while keeping these questions in mind 5. Final Thoughts Writing readable code is not just a technical skill—it’s an act of kindness to your future self and fellow developers. Even with the rise of AI, tasks like designing, explaining, deciding, and sharing intent are still human domains. That’s the real skill developers will need moving forward. May your code support your team and your future self. Think about what “good code” means to you—in your own words. ▼Recommended Books and Resources  “The Art of Readable Code” by Dustin Boswell and Trevor Foucher, translated by Masanori Kado, O'Reilly Japan