プリンキピア

第11章Webアプリケーション開発

11.1 Modern Web Applications Architectures11.1 現代のWebアプリケーションのアーキテクチャ

Learning Objectives学習目標
By the end of this section, you will be able to:
この節を終えると、次のことができるようになる。
• Understand the use of server-side rendering and MVC patterns
• サーバー側でのレンダリングとMVCパターンの用途を理解する。
• Relate to the technology used to create responsive Web 2.0 applications
• レスポンシブなWeb 2.0アプリケーションを作る技術について理解する。
• Become familiar with the technology used to create native mobile applications
• ネイティブモバイルアプリケーションの作成に使う技術に習熟する。
• Understand how to create Web 3.0 applications as well as hybrid Web 2.0/3.0 applications
• Web 3.0アプリケーションと、Web 2.0/3.0を組み合わせたアプリケーションの作成方法を理解する。
The World Wide Web, or the Web as it is known today, started as a way to link content (primarily text and images) stored on different servers or machines. It was invented by Tim Berners-Lee in 1989 while he worked as a researcher at the European Organization for Nuclear Research (CERN), home to the European Particle Physics Laboratory. Sir Tim Berners-Lee was knighted by Queen Elizabeth II in 2004 for his pioneering work. He created the Hypertext Transfer Protocol (HTTP) that operates on top of Transmission Control Protocol/Internet Protocol (TCP/IP), the principal protocols used on the Internet. Clients (web browsers) transmit HTTP requests to a web server, which is a software application that runs at a Uniform Resource Locator (URL) that specifies a location on the Web to access it, and responds by providing pages rendered in the hypertext markup language (HTML). This simple request and response paradigm, a client-server model, was easy to implement and allowed for the rapid growth of the Web. This phase of the Web, which began after 1989 and ended around 2004, would become known as Web 1.0, a period where the user’s interaction was limited primarily to reading and selecting web pages. A web page is a document commonly written in HTML and viewed in a browser. Figure 11.2 shows a simple Web 1.0 architecture and common usage. An encryption layer was later added to the HTTP protocol, which resulted in creating the HTTPS protocol. This made it possible to protect the sharing of sensitive information over the Web from eavesdropping attacks. While web servers only served web pages initially, a Common Gateway Interface (CGI) was subsequently added after the initial implementation of web servers to make it possible to link to applications via URLs on the Web.
英語のヒント
World Wide Web、すなわち現在Webと呼ばれているものは、異なるサーバーや機械に保存されたコンテンツ(主に文章と画像)を結び付ける方法として始まった。1989年に、欧州素粒子物理学研究所のある欧州原子核研究機構(CERN)で研究者として働いていたティム・バーナーズ=リーが考案した。その先駆的な仕事によって、サー・ティム・バーナーズ=リーは2004年にエリザベス2世からナイトの称号を授けられた。彼は、インターネットの主要なプロトコルであるTransmission Control Protocol/Internet Protocol(TCP/IP)の上で動作する、Hypertext Transfer Protocol(HTTP)を作った。クライアント(Webブラウザー)は、WebサーバーにHTTPリクエストを送る。Webサーバーは、Web上のアクセス先を指定するUniform Resource Locator(URL)で動作し、ハイパーテキストマークアップ言語(HTML)で描画されるページを返すソフトウェアアプリケーションである。この単純な要求と応答の仕組み、すなわちクライアント・サーバーモデルは、実装しやすく、Webの急速な成長を可能にした。1989年以降に始まり2004年ごろに終わったこの段階は、のちにWeb 1.0と呼ばれるようになる。この時期の利用者の操作は、主にWebページを読んだり選んだりすることに限られていた。Webページは、通常HTMLで書かれ、ブラウザーで閲覧する文書である。図11.2は、単純なWeb 1.0のアーキテクチャと一般的な使い方を示している。のちにHTTPプロトコルへ暗号化の層が追加され、HTTPSプロトコルが生まれた。これにより、Web上で機密情報を共有する際に、盗聴攻撃から保護できるようになった。当初、WebサーバーはWebページだけを提供していたが、最初の実装の後でCommon Gateway Interface(CGI)が追加され、Web上のURLを通じてアプリケーションに接続できるようになった。
Figure 11.2

attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license · CC BY 4.0 · Source出典

Figure 11.2 This architecture outlines a user’s interaction with a Web 1.0 website. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図11.2 このアーキテクチャは、利用者とWeb 1.0のWebサイトとのやり取りの概要を示している。(出典:Copyright Rice University, OpenStax、CC BY 4.0ライセンス)
As the Web evolved from this basic architecture, the need for more dynamic and interactive experiences became apparent. Users were no longer content with simply viewing static pages; they wanted to contribute content and engage with other users. Also called online publishing, web publishing publishes content on the Web while applying traditional publishing models. It was akin to digitizing an encyclopedia (images and text) and putting it online with hyperlinks. Today, simple websites with limited functionality, such as early blogs or static sites, still follow this model. A more interactive model that could scale to meet user demand was needed to support users’ desire to provide content and interact with other users. A design pattern is a reusable solution to a common software design problem. Figure 11.3 illustrates the Model-View-Controller (MVC) design pattern that was employed to separate a traditional web application’s data model, presentation, and business logic layers into its components.
英語のヒント
この基本的なアーキテクチャからWebが進化するにつれて、より動的で対話的な体験の必要性が明らかになった。利用者は静的なページを見るだけでは満足せず、コンテンツを投稿したり、ほかの利用者と関わったりすることを望んだ。Web出版はオンライン出版とも呼ばれ、従来の出版モデルを適用しながらコンテンツをWeb上で公開することである。これは、百科事典の画像や文章をデジタル化し、ハイパーリンクを付けてオンラインに載せることに似ていた。今日でも、初期のブログや静的サイトのように機能が限られた単純なWebサイトは、このモデルに従っている。コンテンツを提供し、ほかの利用者と交流したいという要望に応えるには、利用者の需要に合わせて規模を拡大できる、より対話的なモデルが必要だった。デザインパターンは、ソフトウェア設計でよくある問題に対して再利用できる解決策である。図11.3は、従来型のWebアプリケーションのデータモデル、表示、ビジネスロジックの各層をコンポーネントに分けるために用いられた、Model-View-Controller(MVC)のデザインパターンを示している。
Figure 11.3

attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license · CC BY 4.0 · Source出典

Figure 11.3 This figure shows a user’s interaction with the Model-View-Controller pattern. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図11.3 Model-View-Controllerパターンにおける利用者のやり取りを示した図。(出典:Copyright Rice University, OpenStax、CC BY 4.0ライセンス)
The original implementation of the MVC pattern on the Web was such that the View would send requests to the Controller and the Controller obtained data from the Model and rendered it within HTML pages that were passed to browsers for presentation purposes. AJAX technology was later introduced to enable a more complete implementation of MVC on the Web that allowed asynchronous updates to page components and did not require refreshing pages in the browser to fetch data.
英語のヒント
Web上でのMVCパターンの最初の実装では、ViewがControllerに要求を送り、ControllerがModelからデータを取得してHTMLページの中へ描画し、そのページを表示のためにブラウザーへ渡していた。その後、AJAX技術が導入された。これによって、Web上でMVCをより完全に実装できるようになり、ページの構成要素を非同期に更新でき、データを取得するためにブラウザーでページを再読み込みする必要もなくなった。
Following Moore’s law, which states that the number of transistors on an integrated circuit doubles roughly every two years, the processing power of smaller devices like laptops, tablets, and mobile phones became the preferred way users interacted on the Web. As Internet data transfer speeds and bandwidth increased through better hardware, fiber-optic cables, and mobile wireless technology, the rendering of web applications’ interactive interfaces moved from the server side to the client side. This led to being able to run native applications (apps) on mobile wireless phones that could take advantage of specific device rendering features. In a paradigm shift that was opposite to web apps, the data model moved off the phone and onto remote servers. These solutions led to a richer user experience known as Web 2.0, which is a phase of the Web focused on social interactions. This phase started in 2004, and social media websites using Web 2.0, such as Facebook (now Meta) and Twitter (now X), are well-known examples of this web phase of social interactivity.
英語のヒント
集積回路上のトランジスター数はおよそ2年ごとに倍になるというムーアの法則に従い、ノートパソコン、タブレット、携帯電話のような小型端末の処理能力を利用することが、Web上でやり取りする利用者に好まれる方法となった。ハードウェア、光ファイバーケーブル、モバイル無線技術の向上によって、インターネットのデータ転送速度と帯域幅が増すと、Webアプリケーションの対話的なインターフェースの描画処理は、サーバー側からクライアント側へ移った。これにより、モバイル無線端末上で、端末固有の描画機能を活用できるネイティブアプリケーション(アプリ)を動かせるようになった。Webアプリとは逆の発想の転換として、データモデルは電話機の外へ、遠隔のサーバー上へ移った。これらの仕組みによって、Web 2.0と呼ばれる、より豊かな利用体験が生まれた。Web 2.0は、社会的な交流に重点を置くWebの段階である。この段階は2004年に始まった。Facebook(現在のMeta)やTwitter(現在のX)などのWeb 2.0を使ったソーシャルメディアのサイトは、社会的な相互交流を特徴とするこのWebの段階のよく知られた例である。
The next phase of the web, Web 3.0, which is a phase of the Web where user activities may focus on decentralized access to solutions and data, is seeing a shift from the more traditional client-server model to a peer-to-peer networking model. A peer-to-peer (P2P) network is one in which devices connect and can share data and processing without needing a centralized server. Peers in this scheme can perform the role of a traditional client, server, or both. This shift fosters a trusted, decentralized, and open web, where large companies do not own the data, but rather where data is collectively owned by users. The use of other technologies like generative artificial intelligence (GenAI), which is powered by machine learning, aims to improve information access by mediating end-user searches to generate corresponding meaningful information out of the content available on the Web. While the benefits of artificial intelligence and machine learning are vast, enabling enhanced data processing and decision-making, it is equally important to consider the risks. These technologies can pose ethical concerns, such as data privacy issues, biased algorithms, and the potential for misuse, thus highlighting the importance of responsible development and implementation. In particular, while GenAI technology is appealing and can be successful in some cases, GenAI is also known to hallucinate and generate unpredictable and often inaccurate responses to web searches. The exemplar apps of the Web 3.0 and later phases are still to be determined. Still, if the previous phases of the Web are any indication, it will fundamentally change how we operate in an ever-evolving technological world.
英語のヒント
Webの次の段階であるWeb 3.0では、利用者の活動の中心が、解決策やデータへの分散型のアクセスに移る可能性がある。ここでは、従来のクライアント・サーバーモデルから、ピアツーピアのネットワークモデルへの移行が見られる。ピアツーピア(P2P)ネットワークは、中央サーバーを必要とせず、端末同士が接続してデータや処理を共有できるネットワークである。この仕組みのピアは、従来のクライアント、サーバー、または両方の役割を果たせる。この移行は、信頼できる、分散した、開かれたWebを育てる。そこでは、大企業がデータを所有するのではなく、利用者が共同で所有する。機械学習によって動作する生成AI(GenAI)のような別の技術の利用は、最終利用者の検索を仲介し、Web上のコンテンツから検索に対応する意味のある情報を生成することで、情報へのアクセスを改善しようとするものである。AIと機械学習には、データ処理や意思決定の向上など、大きな利点があるが、危険性を考えることも同じくらい重要である。これらの技術は、データのプライバシー、偏りのあるアルゴリズム、悪用の可能性といった倫理上の問題を引き起こしうる。そのため、責任ある開発と実装が重要になる。特に、生成AIは魅力的で、うまく機能する場合もある一方、Web検索に対してハルシネーションを起こし、予測できない、しばしば不正確な回答を生成することも知られている。Web 3.0と、それ以降の段階を代表するアプリは、まだ定まっていない。それでも、これまでのWebの各段階が何らかの手掛かりになるとすれば、進化し続ける技術の世界で私たちが活動する方法を、根本から変えることになるだろう。
Throughout this section, we will discover how the application architectures found in Web 2.0 apps, native mobile apps, and Web 3.0 apps are designed.
この節では、Web 2.0アプリ、ネイティブモバイルアプリ、Web 3.0アプリで使われるアプリケーションアーキテクチャの設計方法を見ていく。