プリンキピア

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

GLOBAL ISSUES IN TECHNOLOGY技術をめぐる世界的な課題
Importance of Internationalization and Localization in Frameworksフレームワークにおける国際化と地域化の重要性
Web applications are used worldwide, and specific internationalization and localization requirements must be observed to facilitate the creation of web applications that people all over the world can use. This can be challenging. To meet internationalization and localization prerequisites, services and products must be flexible to compete in international markets. This includes having the malleability to adapt to the cultural needs of target markets around the world. In global markets, language barriers are just one internationalization and localization issue that must be considered for web applications.1
英語のヒント
Webアプリケーションは世界中で使われる。世界中の人が使えるWebアプリケーションを作りやすくするためには、国際化と地域化についての具体的な要件を守らなければならない。これは容易ではない場合がある。国際化と地域化の前提条件を満たすためには、サービスや製品は、国際市場で競争できる柔軟性を備える必要がある。世界各地の対象市場の文化的な必要に適応できる、しなやかさも含まれる。世界市場では、言語の壁は、Webアプリケーションについて考慮すべき国際化・地域化の問題の1つにすぎない。1

Server-Side Rendering and MVC Patternsサーバー側でのレンダリングとMVCパターン

The Web transitioned from its 1.0 phase, where the primary usage was viewing content composed of text and images, to its 2.0 phase of user interaction. As it evolved, three technologies dominated the Web’s programming landscape, commonly referred to as the trifecta:
英語のヒント
Webは、文章と画像からなるコンテンツの閲覧を主な用途とする1.0の段階から、利用者が相互にやり取りする2.0の段階へ移った。その進化に伴い、一般に「三つ組」と呼ばれる次の3つの技術が、Webプログラミングの世界で主流となった。
• hypertext markup language (HTML): a standard markup language used to describe the structure and content of web pages.
• ハイパーテキストマークアップ言語(HTML):Webページの構造と内容を記述するために使う、標準的なマークアップ言語。
• cascading style sheets (CSS): a standard style sheet language used to alter the presentation style of the content found in HTML (or other markup languages).
• カスケーディングスタイルシート(CSS):HTML(またはほかのマークアップ言語)の内容の表示形式を変更するために使う、標準的なスタイルシート言語。
• JavaScript (JS): a scripting language that adds interactivity to web content and server-side functionality. Various other scripting languages and competing approaches were used prior to the adoption of JavaScript.
英語のヒント
• JavaScript(JS):Webコンテンツに対話的な機能を加え、サーバー側の機能も提供するスクリプト言語。JavaScriptが採用される前には、ほかのさまざまなスクリプト言語や、競合する手法が使われていた。
The adoption of HTML was already a given on the Web, and with the introduction of CSS in 1996, a stronger push for separating content and style was introduced so that the styling of content could be specified solely as part of style sheets rather than HTML tags. Web pages at this time mostly consisted of static content, which would be generated and delivered on the web server. Essentially, the user would select an action in their browser that sent an HTTP request to the server such as the following:
英語のヒント
WebでHTMLを採用することは、すでに当然のこととなっていた。1996年にCSSが登場すると、内容の見た目をHTMLタグではなくスタイルシートだけで指定できるように、内容とスタイルを分離する動きが強まった。当時のWebページは、ほとんどが静的な内容であり、Webサーバー上で生成して配信していた。基本的には、利用者がブラウザー内で操作を選ぶと、次のようにサーバーへHTTPリクエストが送られた。
• When clicking a hyperlink on a web page, the browser would send an HTTP GET request to the web server. This request asked for a specific resource (such as a web page or an image), and the server would respond by sending the requested data back to the browser.
• Webページのハイパーリンクをクリックすると、ブラウザーはWebサーバーにHTTP GETリクエストを送る。この要求は、Webページや画像などの特定のリソースを求めるものであり、サーバーは要求されたデータをブラウザーへ送り返して応答する。
• When filling out a form on a web page and clicking the submit button, the browser would send an HTTP POST request to the server. This request included the data that was entered (like a username and password), and the server processed it and responded accordingly.
英語のヒント
• Webページのフォームに入力し、送信ボタンをクリックすると、ブラウザーはサーバーにHTTP POSTリクエストを送る。この要求には、利用者名やパスワードなどの入力したデータが含まれ、サーバーはそれを処理して、内容に応じて応答する。
1 To learn more, check out Lionbridge’s blog (https://openstax.org/r/76Lionbridge) post about globalization.
1 詳しくは、グローバル化についてのLionbridgeのブログ記事(https://openstax.org/r/76Lionbridge)を参照。
Essentially, the web server performed all the HTML content rendering on the server side, and the client (web browser) would present what it received. The browser in this model acts as a thin client, as it has minimal functionality. Figure 11.4 illustrates the components of a traditional Web 2.0 architecture using Java-based technologies. Notice the shift in user interaction with the website compared with a Web 1.0 website. Also note that users are able to interact with applications via an application server that can retrieve data from a database or file system. This enables support for managing web sessions that allow navigation across multiple pages.
英語のヒント
基本的に、Webサーバーがサーバー側でHTMLコンテンツのレンダリングをすべて行い、クライアント(Webブラウザー)は受信したものを表示する。このモデルでは、ブラウザーは最小限の機能だけを持つため、シンクライアントとして動作する。図11.4は、Javaを基盤とする技術を使った、従来型のWeb 2.0アーキテクチャの構成要素を示している。Web 1.0のWebサイトと比べて、利用者とサイトのやり取りがどのように変化したかに注目しよう。また、利用者は、データベースやファイルシステムからデータを取り出せるアプリケーションサーバーを介して、アプリケーションとやり取りできる。この仕組みによって、複数のページを行き来できるWebセッションを管理できるようになる。
Figure 11.4

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

Figure 11.4 This illustrates a user’s interaction with a traditional Web 2.0 architecture. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図11.4 従来型のWeb 2.0アーキテクチャにおける利用者のやり取りを示している。(出典:Copyright Rice University, OpenStax、CC BY 4.0ライセンス)
Many of the original web applications were stateless, meaning that prior requests had no bearing on future requests. For example, it was not possible to create a shopping cart as part of a web session that would keep track of the session and what was purchased on a site and maintain the state (i.e., content in this case) of the cart. In contrast, a stateful application is software that maintains the state of an application over time, while in the case of a stateless application, state is not maintained by the system and previous actions do not impact future ones. Stateless applications are simpler and easier to implement and maintain but offer limited functionality.
英語のヒント
初期のWebアプリケーションの多くは、ステートレスだった。つまり、以前の要求が、その後の要求に影響しなかった。たとえば、セッションとサイトで購入したものを追跡し、カートの状態(この場合は中身)を維持するショッピングカートを、Webセッションの一部として作成することはできなかった。これに対し、ステートフルなアプリケーションは、時間がたってもアプリケーションの状態を維持するソフトウェアである。一方、ステートレスなアプリケーションでは、システムが状態を維持せず、過去の操作がその後の操作に影響しない。ステートレスなアプリケーションは単純で、実装と保守が容易だが、提供できる機能は限られる。
As previously mentioned, Web 2.0 was partly driven by user demand for more interactive functionality. Interactivity requires maintaining some state (e.g., the web session and the content of the cart as per the previous example), thereby increasing the system’s complexity. This increased the demands on the web server for almost all the processing needed to generate and present the website content. Increased functionality led to more complex systems, and a clear separation of responsibility between the website’s rendition, business logic (i.e., the logic implemented as part of the web application), and persistence layers were needed to improve the quality and performance of the website while leveraging engineering expertise in given domains.
英語のヒント
すでに述べたように、Web 2.0を促した要因の1つは、より対話的な機能を求める利用者の要望だった。対話性を持たせるには、前の例でいうWebセッションやカートの中身など、何らかの状態を維持する必要があり、その結果、システムは複雑になる。Webサイトの内容の生成と表示に必要な、ほぼすべての処理について、Webサーバーにかかる負担が増した。機能が増えるとシステムは複雑になる。Webサイトの品質と性能を高め、各領域の技術的な専門知識を活用するためには、Webサイトの描画、ビジネスロジック(Webアプリケーションの一部として実装する処理)、永続化の各層の間で、責任を明確に分離する必要があった。
As you learned in Chapter 10 Enterprise and Solution Architectures Management, the Model-View-Controller pattern is tailored to address this separation of responsibility. In the MVC pattern, the Model is the persistence layer responsible for data storage and retrieval. It has a well-defined API that the Controller uses. The View is the presentation layer that handles the user interface. Finally, the Controller acts as the business logic layer that performs processing and enforces rules to generate applicable content within a given application domain and separates the user interface from the data. It also has a well-defined API that the View understands. The best-practice design concept used to create software systems in a way that ensures weak associations with other components is called loose coupling. This concept allows for separation of concerns between components, which leads to maintaining high cohesion within websites’ functionalities. MVC components are loosely coupled in that the various components can interact with one another to access the specific functionalities provided by each component. High cohesion ensures that everything that is needed to provide a specific functionality is included in one of the components. For example, on a banking website, functionality for deposits and withdrawals may be collocated on the server within the same component to ensure high cohesion; however, features for applying for a loan may be located within another component. Three popular server-side web application frameworks that implemented the MVC pattern were Apache Struts, ASP.NET, and Ruby on Rails.
英語のヒント
第10章「エンタープライズアーキテクチャとソリューションアーキテクチャの管理」で学んだように、Model-View-Controllerパターンは、この責任の分離に対応するよう作られている。MVCパターンでは、Modelはデータの保存と取得を担う永続化の層であり、Controllerが利用する、明確に定義されたAPIを持つ。Viewは、利用者インターフェースを扱う表示の層である。最後に、Controllerはビジネスロジックの層として働く。特定のアプリケーション領域で、処理を実行し、規則を適用して、適切な内容を生成し、利用者インターフェースとデータを分離する。Controllerも、Viewが理解する、明確に定義されたAPIを持つ。ほかのコンポーネントとの結び付きが弱くなるようにソフトウェアシステムを作る、優れた設計の考え方を疎結合という。この考え方によって、コンポーネント間で関心事を分離でき、Webサイトの各機能の中で高い凝集度を保てる。MVCの各コンポーネントは、互いにやり取りして、それぞれが提供する特定の機能を利用できるという意味で、疎結合になっている。凝集度が高いということは、特定の機能の提供に必要なものがすべて、1つのコンポーネントに含まれていることを意味する。たとえば銀行のWebサイトでは、高い凝集度を保つため、入金と出金の機能をサーバー上の同じコンポーネントにまとめ、融資を申し込む機能は別のコンポーネントに置く場合がある。MVCパターンを実装した、よく使われたサーバー側のWebアプリケーションフレームワークには、Apache Struts、ASP.NET、Ruby on Railsがあった。