プリンキピア

第9章ソフトウェア工学

Software Reuseソフトウェアの再利用

When constructing software, developers commonly use libraries and frameworks, which consist of code that was written by other developers. Libraries typically provide some functions, which you can call in your code, and frameworks typically provide application skeletons, which can call your code. For example, you can have a library that provides encryption functionality and a framework that facilitates the development of web applications. Both libraries and frameworks are common in software development, and it is common to combine them. Libraries can be static, which are linked to your code at compile time, or dynamic, which are linked to your code when it executes. Because static libraries are linked at compile time, you must recompile the program when the library is modified. On the other hand, a dynamic library is in a separate file, and thus it can evolve independently of your code.
英語のヒント
ソフトウェアを構築する際、開発者は一般に、ほかの開発者が書いたコードからなるライブラリやフレームワークを使う。ライブラリは通常、自分のコードから呼び出せる関数を提供し、フレームワークは通常、自分のコードを呼び出せるアプリケーションの骨組みを提供する。たとえば、暗号化の機能を提供するライブラリや、Webアプリケーションの開発を容易にするフレームワークがある。どちらもソフトウェア開発では広く使われ、組み合わせて使うことも一般的である。ライブラリには、コンパイル時に自分のコードへリンクする静的ライブラリと、コードの実行時にリンクする動的ライブラリがある。静的ライブラリはコンパイル時にリンクするため、ライブラリを変更したらプログラムを再コンパイルしなければならない。一方、動的ライブラリは別のファイルになっており、自分のコードとは独立して発展させることができる。
Some programming languages, such as Java, provide ready-to-use code as part of a language library. That code may be invoked via an application programming interface (API) and it involves implementation of common data structures and operations on them. Software applications may also leverage external APIs that allow developers to access functionality or data. For example, the United States Postal Service (USPS) provides an API that can be used to get shipping rates, track packages, schedule package pickups, and more. There is no need for a developer to write new code to do this, but rather they can tap into the USPS API instead.
英語のヒント
Javaなどの一部のプログラミング言語は、言語ライブラリの一部として、そのまま使えるコードを提供する。そのコードはアプリケーションプログラミングインターフェース(API)を通して呼び出せ、一般的なデータ構造やそれに対する操作の実装を含んでいる。ソフトウェアアプリケーションは、開発者が機能やデータにアクセスできる外部APIを活用することもある。たとえば米国郵便公社(USPS)は、配送料の取得、荷物の追跡、集荷の予約などに利用できるAPIを提供する。開発者がこれらを行う新しいコードを書く必要はなく、代わりにUSPSのAPIを利用できる。
It might seem that we do not need to write code anymore because we can assemble applications from existing components, but, unfortunately, it does not work this way. One of the reasons is that we usually want to customize functionality, and another reason is that even if an existing component is a good fit for a project, we are often not allowed to use it due to legal reasons. Each component is published under legal terms called licenses, and if we want to use it, we must follow these terms. For example, components published under the GNU General Public License require software that uses them to be published under the same license, which is usually not acceptable in commercial environments.
英語のヒント
既存の部品からアプリケーションを組み立てられるのだから、もうコードを書く必要はないように思えるかもしれない。しかし、残念ながらそうはいかない。理由の一つは、通常は機能を自分の用途に合わせたいからである。もう一つは、既存の部品がプロジェクトにうまく適合していても、法的な理由で利用を認められない場合が多いからである。それぞれの部品はライセンスと呼ばれる法的条件の下で公開され、使いたい場合はその条件に従わなければならない。たとえば、GNU一般公衆ライセンスの下で公開された部品を使うと、それを使うソフトウェアも同じライセンスで公開することが要求されるが、商用の環境では通常、これは受け入れられない。
TECHNOLOGY IN EVERYDAY LIFE日常生活の中の技術
Libraries on Your Computer自分のコンピューターにあるライブラリ
Code reuse and the use of libraries is extremely common. In fact, if you look at the files on a Microsoft Windows computer, you will find that a plethora of libraries are used by the Windows operating system itself. The files that have an extension of .DLL are library files where DLL stands for dynamic-link library.
英語のヒント
コードの再利用とライブラリの利用は、非常に一般的である。実際にMicrosoft Windowsのコンピューターのファイルを見ると、Windowsのオペレーティングシステム自体が、大量のライブラリを使っていることが分かる。拡張子が.DLLのファイルがライブラリファイルであり、DLLはdynamic-link library、すなわち動的リンクライブラリの略である。
On a computer running Microsoft Windows, do a search in Windows File Explorer using “*.dll” to view a list of dynamic-link libraries. Notice how many there are and the dates they were updated. Many of the Windows operating system files are DLL files that get updated at a different frequency as compared to the operating system. The names of some of the files will give you an idea of what the code within them likely does. You can, of course, attempt a similar search for a computer running on Apple’s operating system.
英語のヒント
Microsoft Windowsが動作するコンピューターで、Windowsのエクスプローラーを使い「*.dll」を検索し、動的リンクライブラリの一覧を表示しよう。数の多さと、更新された日付に注目する。Windowsオペレーティングシステムのファイルの多くはDLLファイルであり、オペレーティングシステムとは異なる頻度で更新される。一部のファイルでは、名前から、中のコードが何をするものかを推測できる。もちろん、Appleのオペレーティングシステムが動作するコンピューターでも、同じような検索を試すことができる。
Patternsパターン
A pattern is a high-level concept that supports the idea of reuse and provides reusable solutions to problems often encountered when building software. Patterns are not backed up by any theory; they relate to solutions that were observed in practice at various levels of abstraction and proved successful. In general, patterns are discussed in terms of their meaning, their intent, and the benefits of using them across many software engineering areas. Patterns are typically organized hierarchically in pattern catalogs using descriptive pattern templates. Pattern languages may be used to describe the compatibility between various patterns and help weave them together whenever applicable.
英語のヒント
パターンとは、再利用という考えを支える高水準の概念であり、ソフトウェアの構築時によく遭遇する問題に、再利用できる解決策を提供するものである。パターンは何らかの理論によって裏付けられているのではなく、さまざまな抽象度で実践の中に見いだされ、成功が確認された解決策に関わるものである。一般に、パターンは、その意味、意図、多くのソフトウェア工学の分野で使う利点という観点から論じられる。通常は、記述用のパターンテンプレートを使い、パターンカタログ内で階層的に整理する。パターン言語は、さまざまなパターンの適合性を記述し、適用可能な場面でそれらを組み合わせる助けとして使われることがある。
Software engineers are likely to encounter two broad categories of patterns depending on whether they are designing a software architecture model or mapping it to a corresponding implementation architecture tailored to the platform or environment the solution is meant to be deployed onto. Patterns used to model software architectures include architectural style, architectural patterns, and design patterns, an architectural model, or an implementation of such.
英語のヒント
ソフトウェアエンジニアが遭遇しやすいパターンは、大きく二つの種類に分かれる。どちらになるかは、ソフトウェアアーキテクチャモデルを設計するのか、それとも、そのモデルを、仕組みの配備先となるプラットフォームや環境に合わせた対応する実装アーキテクチャへ写すのかによる。ソフトウェアアーキテクチャのモデル化に使うパターンには、アーキテクチャスタイル、アーキテクチャパターン、デザインパターン、アーキテクチャモデル、またはその実装がある。
As you learned earlier in the chapter, an architectural style is a transformation that is imposed on the design of an entire system. The intent is to establish a structure for all components of a system under development. Examples of architectural styles for distributed systems include the object management architecture (OMA), service-oriented architecture (SOA), multitier architecture, and peer-to-peer decentralized architecture. Note that multiple architectural styles may be combined to create a hybrid architecture style. An architectural pattern is part of a category of patterns that focus on the architecture of software. They tend to be more abstract and focused on improving issues such as deployment, availability, maintainability, performance, scalability, security, and testing. A design pattern is a reusable solution to a design problem that software engineers repeatedly encounter while architecting and designing software systems. For example, the design pattern Singleton suggests how to restrict the number of class instances to one. This problem commonly occurs in software systems whenever a class represents a thing or concept that has a single instance. A more complex design pattern is Builder, which allows a software engineer to create an object in steps and is typically used when creation is a complex process.
英語のヒント
この章ですでに学んだように、アーキテクチャスタイルは、システム全体の設計に課す変換である。その目的は、開発中のシステムのすべての部品に対する構造を定めることである。分散システムのアーキテクチャスタイルには、オブジェクト管理アーキテクチャ(OMA)、サービス指向アーキテクチャ(SOA)、多層アーキテクチャ、ピアツーピアの分散型アーキテクチャなどがある。複数のアーキテクチャスタイルを組み合わせて、混成のスタイルを作ることもできる。アーキテクチャパターンは、ソフトウェアのアーキテクチャに重点を置くパターンの種類に属する。より抽象的で、配備、可用性、保守性、性能、スケーラビリティ、セキュリティ、テストなどの問題の改善に重点を置く傾向がある。デザインパターンは、ソフトウェアエンジニアがソフトウェアシステムのアーキテクチャ構築や設計で繰り返し遭遇する、設計上の問題に対する再利用可能な解決策である。たとえばSingletonというデザインパターンは、クラスのインスタンス数を一つに制限する方法を示す。クラスが、一つしか実例のない物や概念を表す場合、ソフトウェアシステムではこの問題がよく生じる。より複雑なデザインパターンにはBuilderがあり、オブジェクトを段階的に作成できるようにする。通常、作成が複雑なプロセスになるときに用いる。
Furthermore, a design pattern imposes a transformation on the design of an architecture of a given architectural pattern. Therefore, architectural and design patterns may be used in conjunction with an architectural style to shape the overall structure of a system. For example, Model-View-Controller (MVC) is a typical architectural pattern that is used to design the software architecture of a multitier system. If the multitier system provides a scoreboard, that feature will leverage a Singleton design pattern to avoid confusion and ensure the existence of a single scoreboard.
英語のヒント
さらに、デザインパターンは、あるアーキテクチャパターンのアーキテクチャの設計に変換を課す。そのため、アーキテクチャパターンとデザインパターンは、アーキテクチャスタイルと併用して、システム全体の構造を形作ることができる。たとえばModel-View-Controller(MVC)は、多層システムのソフトウェアアーキテクチャの設計に使う典型的なアーキテクチャパターンである。その多層システムがスコアボードを提供する場合、その機能ではSingletonデザインパターンを使い、混乱を避け、スコアボードが一つだけ存在することを確かなものにする。
There are many design patterns described in software development literature. The first book collecting design patterns, Design Patterns by Gamma, Helm, Johnson, and Vlissides, was written in 1995 and continues to be available today. More patterns have been identified and shared since that time. You can find many listings of commonly used design patterns online such as the one available on the tutorialspoint (https://openstax.org/r/ 76tutorialspt) website.
英語のヒント
ソフトウェア開発の文献には、多くのデザインパターンが記述されている。最初にデザインパターンをまとめた本は、Gamma、Helm、Johnson、Vlissidesによる『Design Patterns』で、1995年に書かれ、現在も入手できる。それ以降、さらに多くのパターンが見いだされ、共有されてきた。tutorialspoint(https://openstax.org/r/76tutorialspt)のサイトなど、よく使われるデザインパターンの一覧はオンラインでも数多く見つかる。
Each design pattern provides a solution to a problem in a particular context. Thus, design patterns are not universal solutions as they almost always come with disadvantages, and it depends on the context whether the advantages outweigh the disadvantages, which is why it is important to not only be familiar with design patterns, but also to understand their advantages and disadvantages so that you can assess their benefits and drawbacks in a specific context. Design patterns can be applied when you design a software system, or they can be introduced later on in the process of refactoring. They are rarely applied in their pure form as they are described in literature. The more common practice is to tailor them according to the context in which they will be used. It is also common that the code base of a software system may implement several design patterns, which contributes to the superior quality of the system.
英語のヒント
それぞれのデザインパターンは、特定の状況における問題の解決策を提供する。したがって、万能な解決策ではない。ほとんどの場合、何らかの欠点も伴い、利点が欠点を上回るかどうかは状況次第である。このため、デザインパターンを知っているだけでなく、その利点と欠点も理解し、具体的な状況での長所と短所を評価できることが重要である。デザインパターンは、ソフトウェアシステムを設計するときに適用できるほか、後でリファクタリングする過程で導入することもできる。文献に記述された純粋な形のまま適用されることは少ない。一般的には、使う状況に合わせて調整する。また、ソフトウェアシステムのコード基盤に複数のデザインパターンが実装されることも多く、それがシステムの優れた品質に貢献する。