Skip to Content
JavaScriptデザインパターンを学ぶ 第2版
book

JavaScriptデザインパターンを学ぶ 第2版

by Addy Osmani
March 2025
Intermediate to advanced
298 pages
4h 18m
Japanese
O'Reilly Media, Inc.
Content preview from JavaScriptデザインパターンを学ぶ 第2版

第8章. JavaScriptのMV*パターン

この作品はAIを使って翻訳されている。ご意見、ご感想をお待ちしている:translation-feedback@oreilly.com

オブジェクト設計とアプリケーションアーキテクチャは、アプリケーション設計の2つのプリンシパルである。前章では、前者に関連するパターンを取り上げた。この章では、3つの基本的なアーキテクチャパターンを復習する:MVC(Model-View-Controller)、MVP(Model-View-Presenter)、そしてMVVM(Model-View-ViewModel)だ。過去には、これらのパターンはデスクトップやサーバ側のアプリケーションを構造化するために多用されていた。今ではJavaScriptにも適応されている。

現在これらのパターンを使っているJavaScript開発者のほとんどは、MVC/MV*のような構造を実装するために様々なライブラリやフレームワークを利用することを選択しているため、これらのパターンを古典的なものと比較して、これらのソリューションがMVCの解釈においてどのように異なるかを比較する。

MVC/MVVMをベースとした最新のブラウザベースのUIデザインフレームワークの多くでは、モデルレイヤーとビューレイヤーを簡単に見分けることができる。しかし、第3のコンポーネントは名前も関数も異なる。したがって、MV*の*は、異なるフレームワークで第3のコンポーネントがどのような形をとるかを表している。

車々間通信

MVCは、関心事の分離を通じてアプリケーションの構成改善を促すアーキテクチャ・デザインパターンである。ビジネスデータ(モデル)とUI(ビュー)を分離し、第3のコンポーネント(コントローラ)が伝統的にロジックとユーザ入力を管理する。 Trygve Reenskaugが Smalltalk-80(1979年)に取り組んでいたときに初期化したパターンで、当初はModel-View-Controller-Editorと呼ばれていた。MVCは後に1995年のデザインパターンで詳しく説明された:Elements of Reusable Object-Oriented Software(再利用可能なオブジェクト指向ソフトウェアの要素)」(別名「GoF」本)で詳しく説明され、MVCの普及に一役買った。

スモールトーク80 MVC

オリジナルのMVCパターンが何を解決しようとしていたのかを理解することは不可欠だ。なぜなら、MVCパターンはその起源以来、かなり大きく変化してきたからだ。1970年代、GUIはほとんど存在しなかった。セパレーテッド・プレゼンテーション(Separated Presentation)という概念は、現実世界のアイデアをモデル化したドメイン・オブジェクト(例えば、写真や人物)と、ユーザのスクリーンにレンダリングされるプレゼンテーション・オブジェクトを明確に分ける手段として有名になった。

Smalltalk-80のMVC実装はこの概念をさらに進め、アプリケーション・ロジックをUIから分離することを目指した。アプリケーションのこれらの部分を切り離すことで、アプリケーションの他のインタフェースにモデルを再利用することも可能になるという考えだ。Smalltalk-80のMVCアーキテクチャには、注目に値する興味深い点がいくつかある:

  • モデルはドメイン固有のデータを表し、UI(ビューとコントローラ)には無関心だった。モデルが変更されると、モデルはそのオブザーバーに通知する。 ...

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

アルゴリズムクイックリファレンス 第2版

アルゴリズムクイックリファレンス 第2版

George T. Heineman, Gary Pollice, Stanley Selkow, 黒川 利明, 黒川 洋
Node.jsデザインパターン 第2版

Node.jsデザインパターン 第2版

Mario Casciaro, Luciano Mammino, 武舎 広幸, 阿部 和也

Publisher Resources

ISBN: 9798341625952