Program design tools
導入済み
19:05
プログラム開発ライフサイクル
リリースまでに到達した微小なバグを修正するには巨額の費用がかかり、早期に発見するよりも遥かに高い cost が発生します。だからこそ私たちは単にコードをタイピングし始めません。私たちは…に従います。
英語のナレーション・英語と中国語の字幕を切り替え可能
このレッスンの内容
| English | 意味 |
|---|---|
| software engineering/ˈsɒftweə ˌendʒɪˈnɪərɪŋ/ | The planned work of making software that works well and is easy to manage. |
| code/kəʊd/ | Instructions written in a programming language for a computer to follow. |
| design stage | The stage of development that decides how a program will meet its requirements. |
| structure chart/ˈstrʌktʃə tʃɑːt/ | 構造図 |
| state-transition diagram/steɪt trænˈsɪʃn ˈdaɪəɡræm/ | 状態遷移図 |
| pseudocode/ˈsuːdəʊkəʊd/ | 擬似コード |
| Analysis/əˈnæləsɪs/ | The stage of development that identifies what a program must do. |
| data structures/ˈdeɪtə ˈstrʌktʃəz/ | A way of organising and storing data to support particular operations. |
| algorithms/ˈælɡərɪθəmz/ | A finite sequence of precise steps for solving a problem or carrying out a task. |
| modules/ˈmɒdjuːlz/ | Separately organised program components that perform defined tasks and communicate through interfaces. |
| interface/ˈɪntəfeɪs/ | A way for users or programs to communicate with the computer's hardware. |
| flowchart/ˈfləʊtʃɑːt/ | A diagram showing the sequence of steps and decisions in a process or algorithm. |
| logic/ˈlɒdʒɪk/ | The order of steps and decisions used to solve a problem. |
| transition/trænˈsɪʃn/ | A change from one state to another, caused by an event. |
| decomposition/ˌdiːkɒmpəˈzɪʃn/ | 分解 |
| subroutines/ˈsʌbruːtiːnz/ | サブルーチン |
| parameters/pəˈræmɪtəz/ | パラメータ |
| top-down design/tɒp daʊn dɪˈzaɪn/ | トップダウン設計 |
| caller/ˈkɔːlə/ | The program or module that asks another module to run. |
| selection/sɪˈlekʃn/ | Choosing which branch of instructions to execute according to a condition. |
| loop/luːp/ | A structure that repeats a sequence of instructions. |
| Hierarchy/ˈhaɪərɑːki/ | An arrangement of modules in levels showing which modules call others. |
| return value/rɪˈtɜːn ˈvæljuː/ | The value a function passes back to the part of the program that called it. |
| header/ˈhedə/ | The first line of a subroutine, stating its name, parameters and any return type. |
| array/əˈreɪ/ | An indexed collection of elements arranged in one or more dimensions. |
| main program | The top-level part of a program that controls its overall tasks and calls subroutines. |
| procedure/prəˈsiːdʒə/ | A named sequence of instructions that performs a task when called. |
| function/ˈfʌŋkʃn/ | A mapping that assigns exactly one output to each allowed input. |
| passing modes | Ways of passing parameters that determine how a subroutine can use or change data. |
| states/steɪts/ | 状態 |
| events/ɪˈvents/ | An occurrence detected by a program that can trigger a response. |
| action/ˈækʃn/ | Something a system does when an event causes a change of state. |
| start state | The state a system is in when it begins operating. |
| user interface/ˈjuːzə ˈɪntəfeɪs/ | The controls, displays and interaction mechanisms through which a person communicates with a computer system or program. |
| submodules | Smaller modules that carry out parts of the work of a larger module. |
ソフトウェアが工学になった年
- 1968年10月、世界を代表する50人のプログラマがドイツ・ガルミッシュに集まり、大規模プログラムの失敗(遅延、予算超過、信頼性不足)の理由を議論した。彼らは欠けていたものを指し示す用語として ソフトウェアエンジニアリング を造語した。
- 不満は単純だった。建設家は建てる前に図面を描く。エンジニアは切断する前に計算を行う。プログラマは誰にも何を描かせていない状態でコードを入力していたのだ。
- その十年間で生まれた図面こそが、デザイン工程で使用するものとなる:構造化図(プログラムがどのように部分に分解されているかを示す)と状態遷移図(動作を示す)。
- この授業では、それらをどう読むか、どう作成するか、そして構造化図から擬似コードへどう変換するかを学ぶ。
デザインが決定すること
- 分析はプログラムが 何を(what) すべきかを定めた。デザインは どのように(how) を決定する: データ構造、アルゴリズム、モジュール、およびインターフェースである。
- デザイン工程で生み出される図面は、プログラマがコードにできるものである: 1つのアルゴリズムのロジック用 フローチャート、テキストによる同内容の 擬似コード、モジュール用の構造化図、動作用の状態遷移図。
- 各ツールは異なる質問に答え、試験ではどれが適切かを問う。
コード化される前に描かれたあるアルゴリズムのロジック
Software process lab
Classify development examples by the stage or tool they belong to.
構造図
- 構造図は、プログラムがモジュール、サブROUTINES(サブルーチン)、およびそれら間で渡されるパラメータに分解された階層的な分解を示す。このトップダウン設計は、大きな問題をより小さな部分問題に分割し、それぞれが1つのモジュールとなる。
- 各モジュールは長方形で表される。上の呼び出し元と、下の呼び出されるモジュールを結ぶ線がある。同じレベルのモジュールは左から右へ呼ばれる。
- 線の横にある小さな矢印がデータを運ぶ: モジュール内へ 下 に渡されるパラメータ、呼び出し元へ 上 に返される結果。菱形は選択を、曲線矢印ループを表す。

Hierarchy on the lines, data on the arrows

A structure chart shows:
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
A structure chart is the hierarchical breakdown into modules, with parameters down and results up.
Breaking a problem into modules from the top down is called:
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Top-down design produces a modular solution.
例題: 図からシグネチャーを読む
CalculatePay
/ | \
GetEmployee CalculateBonus CalculateTax
returns: takes: sales takes: gross
employeeID returns: bonus returns: tax
GetEmployeeは何も受け取らず従業員IDを返す:FUNCTION GetEmployee() RETURNS INTEGER。CalculateBonusは売上数値を受け取り、ボーナスを返す:FUNCTION CalculateBonus(Sales : REAL) RETURNS REAL。CalculateTaxは総支給額を受け取り、税金を返す。図上のすべての矢印はヘッダーのパラメータまたは戻り値である。図に示されていないパラメータを含むヘッダーは誤りである。
On a structure chart, a small arrow pointing down from the caller into a module shows a ____ passed to it.
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Downward arrows are parameters going in; upward arrows are results returned. Together they give the module's header.
例題: 構造化図を作成する
- あるプログラムは学生の得点を読み込み、平均値を計算して、グレードを出力する。構造図を描け。
- 最上位モジュール:
ProcessStudent。その下に左から右へ:ReadMarks(スコア配列を返す)、CalculateAverage(スコア配列を受け取り平均を返す)、OutputGrade(平均を受け取り何も返さない)。 - 3つが採点対象: 最上位に主要タスクがある階層、実行順のサブタスク、そして正しい方向の矢印上的名前付きパラメータ。ラベルのない矢印は最高でも半点である。

構造化図から擬似コードへ
- 最上位モジュールがメインプログラムとなり、その下の長方形は矢印から読み取ったヘッダーを持つプロシージャまたは関数となる。メインプログラムは左から右の順序でそれらを呼ぶ。
PROCEDURE ProcessStudent()
DECLARE Marks : ARRAY[1:10] OF INTEGER
DECLARE Average : REAL
Marks ← ReadMarks()
Average ← CalculateAverage(Marks)
CALL OutputGrade(Average)
ENDPROCEDURE
- 戻り値がある場合、それは
FUNCTION … RETURNSであり、何も戻さないモジュールはPROCEDUREである。パラメータリストはちょうど下向きの矢印に相当する。
Put the steps of designing a program with a structure chart in order.
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
Top down: task, sub-tasks, data flow, headers, calls. The chart is finished before the first line of code.
A module whose result is returned for use in an expression should be written as a PROCEDURE.
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
A value returned for use in an expression requires a FUNCTION … RETURNS. A PROCEDURE can pass results back through BYREF parameters.
状態遷移図
- 状態遷移図 はシステムの 動作 を文書化する: あり得る 状態 と、それをある状態から別の状態へ移動させる イベント 。
- 各状態は円または角丸ボックス、各遷移は原因となるイベントでラベル付けされた矢印( sometimes 伴うアクション)である。始点状態を示すマーカーがある。
- イベントを待って反応するシステムに適している: 自動販売機、信号機、ドアロック、ユーザーインターフェース。

Every state, every event, every arrow

A state-transition diagram shows:
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
States are circles; transitions are event-labelled arrows. Ideal for vending machines, locks, traffic lights.
What does a state-transition diagram show? Select すべて that apply.
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
States, labelled transitions and the start marker. Timing is not part of the diagram.
演習例:ドアロック図を読む
- 暗号2, 5, 9でロックが解除されます。Lockedから始めます。2を押すとOne digit correctに移動し、そこから5を押すとTwo digits correctに、さらにそこから9を押すとUnlockedになります。
- 待機状態のいずれかから他のキーを押すとLockedに戻ります: 図にはこれらの矢印も示されており、それらを省略した図には欠落があります。Unlocked状態で2を押したらどうなりますか? どの矢印にも書かれていない場合、設計側が未定義です。
- それが図の役割です: 各状態はすべてのイベントに対して何が起こるかを明示する必要があります。したがって、欠落している遷移は顧客ではなく、設計者が紙上で見つけ出します。

A state-transition diagram makes missing or unhandled transitions easy to spot, because every state and the events between them are laid out.
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Seeing every state and event reveals cases you have not handled — e.g. an unexpected second coin in a vending machine.
ツールの選択
- プログラムがモジュールに分割され、その間で何がやり取りされるかを示す: 構造図。
- イベントに対するシステムの時間的な挙動、特にモードを持つ機械やインターフェースの動作を示す: 状態遷移図。
- 1つのアルゴリズムの段階的なロジックを示す: フローチャートまたは擬似コード。どれを選ぶべきか、および理由を述べよ。

Match each design tool to what it shows.
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
Each tool views the design differently — structure (modules), behaviour (states), flow (flowchart) or steps (pseudocode).
A traffic-light controller must respond to a timer and a pedestrian button. Which design tool documents its behaviour best?
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Red, red-and-amber, green, amber are states; the timer and the button are events. A structure chart would show the modules, not the behaviour.
見落としやすいポイント
- 構造図はフローチャートではない。階層とパラメータを示すものであり、モジュール内の意思決定の順序を示すものではない。
- 矢印すべてにパラメータ名または返り値の名前を付け、正しい方向を指し示せ。ラベルのない矢印は何も意味しない。
- 状態とはシステムが待機している状況であり、イベントとはそこに生じる出来事である。「5を押す」はイベントであり、状態ではない。
- 擬似コードの見出しは図と一致させる: 同じパラメータ、同じ返り値、同じ呼び出し順にする。
理解できましたか
- 構造図は、モジュールへのトップダウン分解を示し、パラメータは下向き矢印で渡され、結果はラベル付きの上向き矢印で戻ってくる。
- 擬似コードの見出しから読み取る: 下向きの矢印はパラメータリストであり、上向きの矢印がある場合は
FUNCTION … RETURNSとなり、メインモジュールは左から右へ呼ぶ。 - 状態遷移図は状態とそれらを結ぶイベントを示し、誰にも未定義の遷移を露呈する。
- 分解 → 構造図; 挙動 → 状態遷移図; 1つのアルゴリズムのロジック → フローチャートまたは擬似コード
何が問題でしたか?この内容はサイトの運営チームだけが確認します。