Developing Procedures
도입됨
9:10
알고리즘 및 프로그래밍
백만 명의 이름이 있는 전화번호부를 상상해 보십시오. 하나를 찾아야 합니다. 하나씩 확인하면 하루 종일 걸릴 수도 있습니다. 약…안에 찾을 수 있는 방법이 있습니다.
영어 내레이션 · 영어와 중국어 자막 전환 가능
이 수업의 내용
| English | 의미 |
|---|---|
| define/dɪˈfaɪn/ | 정의 |
| parameters/pəˈræmɪtəz/ | 형식 인자 |
| procedural abstraction/prəˈsiːdʒərəl əbˈstrækʃn/ | 절차 추상화 |
| readability/ˌriːdəˈbɪlɪti/ | 가독성 |
| duplication/ˌdjuːplɪˈkeɪʃn/ | 중복 |
사용자 정의 Procedure 작성
- 사용자 정의 procedure를 작성하는 것은 프로그래밍의 핵심 기술입니다.
- Procedure를 define하려면 명확한 이름, parameters, 그리고 명령어 본체를 부여해야 합니다.
- 그러면 그 작업을 수행해야 할 곳 어디든 procedure를 호출할 수 있습니다.
- 좋은 procedure는 하나의 명확한 일만 수행합니다.
To define a procedure you give it:
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
Those three parts make a reusable procedure.
이 카드는 내용이 수정되어 번역이 업데이트될 때까지 영어로 표시됩니다.
Parameters give flexibility
- Use parameters 形参 so a procedure can work with different input values.
greet(name)can greet anyone, because the caller supplies the name each time.- Without parameters, a procedure could obtain the name in another way, such as from user input.
- Parameters are what make one procedure reusable across many cases.

Decomposing a program into procedures and sub-procedures
Good candidate for a procedure?
Extract a procedure when a chunk of work has one clear purpose or repeats in several places; a unique one-off line does not need its own procedure.
Why does greet(name) use a parameter?
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
The caller supplies a different name each call.
Hiding the implementation details of a procedure behind its name and parameters is ______ abstraction.
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
Procedural abstraction keeps big programs manageable.
이 카드는 내용이 수정되어 번역이 업데이트될 때까지 영어로 표시됩니다.
Procedural abstraction
- Procedures support procedural abstraction 过程抽象 by hiding implementation details behind an interface; they also help break a large problem into smaller, manageable parts.
- Each part becomes a procedure with one clear job.
- You reason about the small parts, not the whole tangled program at once.
- This is how large programs stay understandable.
Putting repeated code inside one procedure mainly reduces:
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
One procedure replaces many copies of the same lines.
With a greet procedure, changing the greeting means editing one place, not three.
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
Fewer places to edit means fewer chances for errors.
A well-named procedure like calculateTax() helps a reader understand the intent quickly.
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
Good names improve readability and reuse.
두 가지 주요 이점
- 잘 명명된 procedure는 readability와 재사용성을 향상시킵니다: 읽는 사람이
calculateTax()를 보면 의도를 파악합니다. - 반복되는 코드를 procedure에 배치하면 duplication을 줄입니다.
중복 제거. 프로그램이 같은 3줄 인사말을 세 곳에서 출력하는 것은 중복입니다. 해당 줄을 포함하는 하나의 greet(name)을 정의하면, 각 위치에서 단일 호출만 수행하면 됩니다: greet("Ana"), greet("Bo"), greet("Cy"). 인사말을 한 번만 변경하면 세 번 변경할 필요가 없습니다.
절차를 정의하려면 이름, 매개변수, 그리고 본체를 지정해야 합니다. 매개변수를 사용하면 하나의 절차가 다양한 입력(greet(name))을 처리할 수 있습니다. 이를 절차적 추상화라고 하며, 문제를 작은 작업으로 분리하는 것입니다. 이 방식의 장점: 가독성 개선 및 복제 감소(여러 사본 대신 하나의 절차만 수정).
어떤 문제가 있었나요? 사이트 팀만 이 내용을 볼 수 있습니다.