ソフトウェア工学の基本
informationsoftware-engineeringundergraduatelecture
data/lecture/information/software-engineering/software-engineering-portal.lecture.n.md
1導入
この講義では、要求から運用と保守までのライフサイクルを通じて、ソフトウェアの品質と変更可能性を管理する方法を説明する。
プログラムが計算結果を返すことは、ソフトウェアの品質の一部にすぎない。利用者の要求との一致、障害時の信頼性、攻撃に対するセキュリティ、変更のしやすさなども評価する必要がある。ソフトウェア工学は、これらを個別の工夫ではなく、体系的な開発・運用活動として扱う。
2要求と受入条件
要求 は、システムが提供すべき機能または満たすべき制約である。
- 機能要求 は、システムが実行すべき処理や提供すべき機能を規定する。
- 非機能要求 は、性能、可用性、セキュリティ、使用性など、機能の品質や制約を規定する。
要求を「高速である」のような曖昧な表現だけで記述すると、実装の完了を判定できない。受入条件 は、要求が満たされたと判断するための観測可能な条件である。たとえば「同時に1000件の要求を処理したとき、95%の応答を200 ms以内に返す」と記述すれば、性能を測定できる。
3設計と変更の局所化
設計 は、要求を実現するために、システムの構成要素、責務、および構成要素間の関係を定める活動である。設計の目的は、単にファイルやクラスを分割することではない。一つの変更理由が多数の構成要素へ波及しないように、責務を配置する。
凝集度 は、一つの構成要素に属する責務がどの程度まとまっているかを表す。結合度 は、構成要素間の依存の強さを表す。一般に、関連する責務を高い凝集度でまとめ、構成要素間の結合度を必要最小限にすると、変更の影響を局所化しやすい。ただし、分割を過度に進めると、インターフェースと通信の複雑性が増加する。
インターフェース は、構成要素が外部へ公開する操作と情報の境界である。入力の前提条件、出力の保証、失敗時の応答を明示すると、内部実装を変更しても利用側への影響を抑制できる。
4テストと検証の水準
テスト は、入力と実行条件を設定し、観測結果を期待結果と比較して欠陥を検出する活動である。テストが成功しても、未実行の入力や状態に欠陥がないことまでは証明できない。このため、要求とリスクに応じて試験範囲を設計する。
- 単体テスト は、関数やモジュールなどの小さな単位を検証する。
- 結合テスト は、データベース、ネットワーク、モジュールなどの境界を介した連携を検証する。
- システムテストは、統合されたシステムがシステム要求を満たすかを検証する。
- 受入テスト は、利用者や発注者の観点から受入条件を評価する。
修正によって既存機能が損なわれることを回帰という。自動化された回帰テストを変更ごとに実行すると、既知の振る舞いが維持されているかを継続的に確認できる。
5変更管理・運用・保守
版管理 は、ソースコード、設定、ドキュメントなどの変更履歴を識別可能な版として記録する。継続的インテグレーションは、開発者が変更を共有された主系列へ頻繁に統合し、そのたびに自動ビルドとテストの結果を得る実践である。これにより、複数の変更の不整合を早期に検出できる。レビューは変更内容を検討する補完的な活動である。
運用 は、配備したシステムを利用可能な状態に維持する活動である。構成を管理し、稼働状態を監視し、障害やセキュリティインシデントへ対応する。監視結果とインシデントの記録は、新たな要求や保守の優先順位へ反映する。
保守 は、運用開始後にソフトウェアを修正し、環境へ適応させ、または品質を改善する活動である。障害の修正だけでなく、新しい要求、依存技術の更新、性能改善、セキュリティの強化も含む。
短期的な納期を優先して設計上の問題を残すと、将来の変更費用が増加することがある。この将来費用を技術的負債として捉える。技術的負債は比喩であり、すべての未改善箇所を直ちに解消すべきことを意味しない。影響と費用を評価して返済の優先順位を定める。
6品質特性とトレードオフ
品質には、機能適合性、信頼性、性能効率性、使用性、セキュリティ、保守性などの複数の特性がある。すべての特性を無制限に最大化することはできない。たとえば、冗長化は可用性を高める一方で、構成と運用を複雑にする。要求、リスク、費用を明示し、トレードオフを合意することが設計判断となる。
7具体例:データベースを利用する履修登録システム
履修登録システムでは、「学生が科目を登録できる」が機能要求となる。「定員を超える登録を許可しない」「二重登録を防止する」は、受入条件として検証できる。設計では、画面、登録規則、SQL による永続化を異なる責務として分離する。
単体テストは登録規則を、結合テストはアプリケーションとデータベースのトランザクションを、受入テストは利用者の操作手順を検証する。要件変更によって抽選方式を導入するとき、責務の分離と回帰テストが変更の影響範囲を明確にする。
8要点
- 要求と受入条件は、実装とテストの共通基準となる。
- 設計は責務とインターフェースを定め、変更の影響を局所化する。
- テストは欠陥を検出するが、欠陥が存在しないことの一般的な証明ではない。
- 版管理、レビュー、継続的インテグレーションは、変更を追跡し、統合時の問題を早期に検出する。
- 品質特性間のトレードオフは、要求、リスク、費用に基づいて判断する。
9次に進む講義
ソフトウェアを複数の機器や拠点にまたがるシステムとして構成するには、情報を信号として伝送する仕組みも必要となる。次のポータルでは、通信を支える信号、雑音、変調などを扱う。
data/lecture/information/communications/communications-engineering-portal.lecture.n.md
Software Engineering Fundamentals
data/lecture/information/software-engineering/software-engineering-portal.lecture.n.md
1Introduction
This lecture explains how to manage software quality and changeability throughout the lifecycle from requirements to operation and maintenance.
Producing a computed result is only one aspect of software quality. A system must also be evaluated for conformance to user requirements, reliability under failure, security against attacks, and ease of change. Software engineering treats these concerns through systematic development and operational activities rather than as isolated implementation techniques.
2Requirements and Acceptance Criteria
A requirement is a capability that a system must provide or a constraint that it must satisfy.
- A functional requirement specifies behavior or functionality that the system must provide.
- A non-functional requirement specifies quality or constraints such as performance, availability, security, and usability.
An ambiguous statement such as “the system must be fast” does not determine when implementation is complete. An acceptance criterion is an observable condition for deciding whether a requirement has been satisfied. For example, “when processing 1,000 concurrent requests, return 95 percent of responses within 200 ms” makes performance measurable.
3Design and Localization of Change
Design is the activity of defining a system's components, their responsibilities, and their relationships in order to realize requirements. Its purpose is not merely to divide code into files or classes. Responsibilities should be arranged so that one reason for change does not propagate through many components.
Cohesion describes how closely the responsibilities within one component belong together. Coupling describes the strength of dependencies between components. In general, grouping related responsibilities with high cohesion and limiting coupling helps localize change. Excessive decomposition, however, increases the complexity of interfaces and communication.
An interface is the boundary of operations and information that a component exposes. Stating input preconditions, output guarantees, and failure behavior limits the effect on clients when an internal implementation changes.
4Testing and Levels of Verification
Testing is the activity of configuring inputs and execution conditions and comparing observed results with expected results to detect defects. A successful test does not prove that no defect exists for unexecuted inputs or states. Test coverage must therefore be designed according to requirements and risk.
- A unit test verifies a small unit such as a function or module.
- An integration test verifies interaction across boundaries such as modules, databases, or networks.
- A system test verifies the integrated system against system requirements.
- An acceptance test evaluates acceptance criteria from the perspective of a user or customer.
A change that damages existing behavior causes a regression. Running automated regression tests after each change continuously checks whether established behavior remains intact.
5Change Management, Operation, and Maintenance
Version control records the history of source code, configuration, and documentation as identifiable versions. Continuous integration is the practice of frequently integrating changes into a shared mainline and obtaining automated build and test feedback for each integration. It detects inconsistencies among changes early. Review is a complementary activity that examines the content of a change.
Operation is the activity of keeping a deployed system available for use. It includes managing configuration, monitoring operational state, and responding to failures and security incidents. Monitoring results and incident records inform new requirements and maintenance priorities.
Maintenance is the activity of correcting software, adapting it to its environment, or improving its quality after deployment. It includes not only defect correction but also new requirements, dependency updates, performance improvement, and security strengthening.
Prioritizing a short-term deadline can leave design problems that increase the cost of future change. This future cost can be described as technical debt. Technical debt is a metaphor; it does not imply that every imperfection must be removed immediately. Teams evaluate impact and cost to prioritize repayment.
6Quality Attributes and Trade-offs
Quality comprises multiple attributes, including functional suitability, reliability, performance efficiency, usability, security, and maintainability. These attributes cannot all be maximized without limit. Redundancy, for example, can improve availability while making configuration and operation more complex. A design decision makes the relevant requirements, risks, and costs explicit and establishes an agreed trade-off.
7Example: A Database-Backed Course Registration System
In a course registration system, “a student can register for a course” is a functional requirement. “Do not permit registration beyond capacity” and “prevent duplicate registration” can be verified as acceptance criteria. The design separates the user interface, registration rules, and SQL-based persistence as distinct responsibilities.
Unit tests verify registration rules, integration tests verify transactions between the application and database, and acceptance tests verify the user's workflow. When a requirement change introduces a lottery, separated responsibilities and regression tests clarify the affected scope.
8Key Points
- Requirements and acceptance criteria provide a shared basis for implementation and testing.
- Design defines responsibilities and interfaces to localize the effects of change.
- Testing detects defects but does not generally prove their absence.
- Version control, review, and continuous integration track change and detect integration problems early.
- Trade-offs among quality attributes are decided according to requirements, risks, and costs.
9Next Lecture
Systems spanning multiple devices or sites also require mechanisms that transmit information as signals. The next portal addresses signals, noise, modulation, and other foundations of communication.
data/lecture/information/communications/communications-engineering-portal.lecture.n.md