Validation, verification and trace tables
แนะนำใหม่
9:16
รอบชีวิตการพัฒนาโปรแกรม
ทุกแอปในโทรศัพท์ของคุณเขียนโดยบุคคลเช่นนี้ แต่เขาไม่ได้เริ่มด้วยการพิมพ์โค้ด ก่อนบรรทัดแรก ปัญหาถูกศึกษา, ทางออก…
บรรยายภาษาอังกฤษ · สลับคำบรรยายภาษาอังกฤษและภาษาจีนได้
ในบทเรียนนี้
| English | ความหมาย |
|---|---|
| data/ˈdeɪtə/ | Recorded facts, observations or values used for analysis or processing. |
| Validation/ˌvælɪˈdeɪʃn/ | Checking whether data meets specified rules for acceptable values or format. |
| verification/ˌverɪfɪˈkeɪʃn/ | Checking that data has been entered or copied accurately from its source, rather than deciding whether the source itself is correct. |
| trace table/treɪs ˈteɪbl/ | ตารางติดตาม |
| algorithm/ˈælɡərɪθəm/ | A finite sequence of precise steps for solving a problem or carrying out a task. |
| Range check/reɪndʒ tʃek/ | |
| length check/leŋθ tʃek/ | การตรวจสอบความยาว |
| type check/taɪp tʃek/ | |
| presence check/ˈprezəns tʃek/ | การตรวจสอบการมีอยู่ |
| format check/ˈfɔːmæt tʃek/ | |
| check digit/tʃek ˈdɪdʒɪt/ | |
| Visual check/ˈvɪʒuːəl tʃek/ | A person compares the typed data with the original. |
| Double entry/ˈdʌbl ˈentri/ | The data is entered twice and the two copies are compared. |
| test data/test ˈdeɪtə/ | ข้อมูลทดสอบ |
| variable's | |
| normal/ˈnɔːml/ | In testing, ordinary valid input that should be accepted and produce the expected result. |
| abnormal/əbˈnɔːml/ | In testing, invalid or unsuitable input that the program should reject or handle appropriately. |
| extreme/ekˈstriːm/ | |
| boundary/ˈbaʊndəri/ | Input values at, just inside or just outside an allowed limit, used to check a program's handling of its valid range. |
| program/ˈprəʊɡræm/ | A set of instructions specifying operations for a computer to carry out. |
การตรวจสอบและติดตาม
- เมื่อป้อนข้อมูล เราจะ ตรวจสอบ ข้อมูลเพื่อลดข้อผิดพลาด
- การตรวจสอบความถูกต้อง ตรวจสอบว่าข้อมูลสมเหตุสมผล; การยืนยัน ตรวจสอบว่าข้อมูลถูกคัดลอกอย่างถูกต้อง
- ตารางติดตาม (trace table) จะติดตามอัลกอริทึมทีละขั้นตอน
การตรวจสอบความถูกต้อง (Validation)
- การตรวจสอบความถูกต้อง ตรวจสอบว่าข้อมูลมีเหตุผลและเป็นไปตามกฎ (แต่ไม่สามารถตรวจสอบได้ว่าข้อมูลนั้น เป็นความจริง)
- การตรวจสอบช่วง (range check) (อยู่ระหว่างขอบเขต), การตรวจสอบความยาว (length check) (จำนวนตัวอักษรถูกต้อง), การตรวจสอบประเภท (type check) (ชนิดของข้อมูลถูกต้อง), การตรวจสอบการมีอยู่ (presence check) (ไม่ว่างเปล่า), การตรวจสอบรูปแบบ (format check) (รูปแบบถูกต้อง เช่น dd/mm/yyyy) และ เลขยืนยัน (check digit) (ตัวเลขเพิ่มเติมเพื่อยืนยันตัวเลข)

อัลกอริทึมทุกตัวสามารถแยกออกเป็นข้อมูลเข้า, การประมวลผล และข้อมูลออก — ในที่นี้คือการหาค่าเฉลี่ยของคะแนนสามข้อ

Checking that an age is between 0 and 120 is a:
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
A range check confirms a value lies within allowed limits.
Match each validation check to its purpose.
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Presence = not blank; type = right kind of data; format = right pattern.
การตรวจสอบความถูกต้อง (Verification)
- การตรวจสอบความถูกต้อง ตรวจสอบว่าข้อมูลถูกคัดลอกหรือกรอกอย่างถูกต้อง (ไม่มีข้อผิดพลาดจากการพิมพ์)
- การตรวจสอบด้วยสายตา (visual check) — บุคคลหนึ่งเปรียบเทียบข้อมูลที่พิมพ์กับต้นฉบับ
- การกรอกซ้ำ (double entry) — กรอกข้อมูลสองครั้งแล้วเปรียบเทียบสำเนาทั้งสอง

การค้นหาแบบเชิงเส้น (linear search) ตรวจสอบแต่ละรายการตามลำดับตั้งแต่ต้นจนกว่าจะพบค่าที่ต้องการ
Double entry of data is a validation check.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
False. Double entry is a verification check: it confirms data was entered correctly. Validation checks that data is sensible, such as a range or type check.
Entering data twice and comparing the two copies is:
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Double entry is a verification method — the two copies must match.
ตารางติดตามและข้อมูลทดสอบ
- ตารางติดตาม บันทึกค่าของแต่ละตัวแปรขณะอัลกอริทึมทำงาน — เพื่อตรวจสอบว่าทำงานได้ถูกต้องหรือเพื่อเข้าใจว่ามันทำอะไร
- ประเภทของข้อมูลทดสอบ: ปกติ (ยอมรับได้), ผิดปกติ (ปฏิเสธ), สุดขั้ว (ค่าสูงสุด/ต่ำสุดที่ยอมรับได้), ขอบเขต (ค่าที่อยู่ทั้งสองข้างของขอบเขต เช่น 120 และ 121)

ตารางติดตามบันทึกค่าของแต่ละตัวแปรขณะที่โปรแกรมทำงาน

Fill in a trace table
A trace table follows the variables one line at a time. Step through and watch the counter and the running total change — exactly the skill a trace-table exam question tests.
A trace table is used to:
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Tracing helps you check an algorithm works, or work out what it does, by following the variables.
Trace total = 0; FOR i = 1 TO 5: total = total + i. What is total at the end?
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
1+2+3+4+5 = 15 — the value the trace table builds up row by row.
การ์ดนี้เป็นการ์ดใหม่ จึงแสดงเป็นภาษาอังกฤษจนกว่าคำแปลจะพร้อม
Worked example: test data for an exam mark
A program accepts whole-number exam marks from 0 to 100. Give one value of each type of test data.
- Normal: 57 (accepted). Abnormal: −8 or "ten" (rejected). Extreme: 0 and 100, the smallest and largest allowed values (accepted).
- Boundary: test each side of each limit: 100 (accepted) and 101 (rejected); 0 (accepted) and −1 (rejected). The check used is a range check 范围检查, plus a type check for "ten".

A program accepts ages 18 to 65. Which pair is boundary test data for the upper limit?
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Boundary data sits on each side of a limit: 65 should be accepted and 66 rejected.
Typing a new password twice is a validation check.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Double entry is verification: it checks the data was copied correctly, not that it is sensible.
คุณเข้าใจแล้ว
- การตรวจสอบความถูกต้อง = มีเหตุผลหรือไม่? (ช่วง, ความยาว, ประเภท, การมีอยู่, รูปแบบ, เลขยืนยัน)
- การตรวจสอบความถูกต้อง = คัดลอกถูกต้องหรือไม่? (การตรวจสอบด้วยสายตา, การกรอกซ้ำ)
- ตารางติดตาม ติดตามค่าตัวแปรทีละขั้นตอน
- ข้อมูลทดสอบ: ปกติ, ผิดปกติ, สุดขั้ว, ขอบเขต
เกิดปัญหาอะไรขึ้น? เฉพาะทีมเว็บไซต์เท่านั้นที่เห็นข้อมูลนี้