Mục lục bài họcĐang ở d01-b1
Collaboration, Program Purpose and Program Function
Why computing innovations are built by teams
A computing innovation is any innovation that includes a program as an integral part of its function: a ride-sharing app, a smart thermostat, a spreadsheet macro. Almost none of them is written by one person, and the AP framework treats collaboration as a skill, not a soft extra.
Collaboration helps in two different ways. First, it divides the work, so a larger program can be finished in the same time. Second, and more important on the exam, it brings in diverse perspectives. People with different backgrounds notice different needs, different edge cases and different kinds of bias. A team that includes users of different ages, languages or abilities is more likely to discover that a font is unreadable for older users or that a form rejects names with accents.
Common collaboration practices include pair programming (a driver types while a navigator reviews each line, and the two switch roles often), consulting and communicating with the intended users, using shared online tools so that everyone works on the current version, and giving and receiving feedback respectfully. Collaboration also includes acknowledging code, media or ideas that came from someone else: the original author or source should be credited in the program documentation.
Notice what collaboration does not guarantee. Adding people does not automatically remove bias; it helps only when the added perspectives are actually different and are actually listened to. A team of ten people who all test the app on the same phone in the same city has more hands, not more perspectives.
Đổi mới điện toán (computing innovation) là bất kỳ đổi mới nào có chương trình máy tính làm phần cốt lõi trong chức năng của nó: ứng dụng gọi xe, máy điều hoà thông minh, một macro trong bảng tính. Gần như không cái nào do một người viết, và khung chương trình AP coi cộng tác là một kỹ năng được chấm, không phải chuyện phụ.
Cộng tác giúp theo hai kiểu khác nhau. Một là chia việc: chương trình lớn hơn vẫn xong trong cùng thời gian. Hai — và đây là ý đề thi hay hỏi — là mang vào nhiều góc nhìn khác nhau. Người có xuất thân khác nhau nhìn ra nhu cầu khác nhau, ca biên khác nhau, kiểu thiên lệch (bias) khác nhau. Một nhóm có người dùng ở nhiều độ tuổi, ngôn ngữ, khả năng khác nhau sẽ dễ phát hiện rằng cỡ chữ quá nhỏ với người lớn tuổi, hoặc biểu mẫu từ chối tên có dấu.
Các cách cộng tác thường gặp: lập trình cặp (một người lái gõ mã, một người dẫn đường soát từng dòng, đổi vai thường xuyên); hỏi ý kiến và trao đổi với người dùng dự kiến; dùng công cụ chia sẻ trực tuyến để mọi người cùng làm trên bản mới nhất; góp ý và nhận góp ý một cách tôn trọng. Cộng tác còn gồm việc ghi nhận nguồn: đoạn mã, hình ảnh hay ý tưởng lấy từ người khác phải ghi tên tác giả hoặc nguồn trong tài liệu chương trình.
Để ý điều cộng tác không bảo đảm. Thêm người không tự động xoá thiên lệch; nó chỉ giúp khi các góc nhìn thêm vào thật sự khác và thật sự được lắng nghe. Mười người cùng thử ứng dụng trên cùng một loại điện thoại, ở cùng một thành phố thì nhiều tay hơn chứ không nhiều góc nhìn hơn.
Purpose, function, inputs, outputs and events
The exam separates two descriptions of a program that students tend to blur. The purpose of a program is why it exists: the problem it solves or the creative interest it pursues. Its function is what it does when it runs: the behaviour a user can observe. "Help a family avoid buying food they already have" is a purpose. "Displays the items in the pantry list that expire within three days" is a function.
A program's behaviour is driven by inputs, data sent to the computer for processing. Inputs can be tactile (a tap or a click), audio (a voice command), visual (a camera frame) or text (typed characters), and they can also come from another program or a file. Outputs are data sent from the program to a device or another program: text on a screen, a sound, a vibration, a file written to disk.
Many modern programs are event-driven. An event is an action that supplies input — a button press, a key press, a mouse movement, a timer reaching zero. Each event is linked to a block of code called a handler, and that block runs when the event occurs. As a result, the statements of an event-driven program are not necessarily executed in the order in which they appear in the source code. The user's sequence of actions, not the line numbers, determines the order.
When you trace an event-driven program, therefore, list the events in the order they happen and apply each handler to the current values of the shared variables. A handler that ran earlier may have changed the values that a later handler reads.
Đề thi tách hai cách mô tả chương trình mà học viên hay nhập làm một. Mục đích (purpose) là vì sao chương trình tồn tại: vấn đề nó giải quyết hoặc hứng thú sáng tạo nó theo đuổi. Chức năng (function) là chương trình làm gì khi chạy: hành vi mà người dùng quan sát được. "Giúp gia đình khỏi mua lại thực phẩm đã có" là mục đích. "Hiện các món trong danh sách tủ bếp sắp hết hạn trong 3 ngày" là chức năng.
Hành vi của chương trình được điều khiển bởi đầu vào (input) — dữ liệu gửi vào máy để xử lý. Đầu vào có thể là chạm/nhấp (xúc giác), âm thanh (lệnh giọng nói), hình ảnh (khung hình camera) hay văn bản (ký tự gõ), và cũng có thể đến từ một chương trình khác hoặc một tệp. Đầu ra (output) là dữ liệu chương trình gửi tới thiết bị hay chương trình khác: chữ trên màn hình, âm thanh, rung, tệp ghi xuống đĩa.
Nhiều chương trình hiện đại là hướng sự kiện (event-driven). Sự kiện là một hành động cung cấp đầu vào — nhấn nút, gõ phím, di chuột, đồng hồ hẹn giờ về 0. Mỗi sự kiện gắn với một khối lệnh gọi là trình xử lý, và khối đó chạy khi sự kiện xảy ra. Hệ quả: các câu lệnh của chương trình hướng sự kiện không nhất thiết chạy theo thứ tự chúng xuất hiện trong mã. Chuỗi thao tác của người dùng, không phải số dòng, quyết định thứ tự.
Vì vậy khi truy vết chương trình hướng sự kiện: liệt kê sự kiện theo đúng thứ tự xảy ra, rồi áp từng trình xử lý lên giá trị hiện tại của các biến dùng chung. Trình xử lý chạy trước có thể đã đổi giá trị mà trình xử lý chạy sau sẽ đọc.
items. Nếu người dùng nhấn Thêm hai lần, chờ hẹn giờ, rồi gõ Enter thì màn hình hiện 0 — dù dòng items ← items + 1 nằm trên cùng trong mã.A student describes her app: “Many students at my school forget to drink water during exams week. My app lets a student set a daily goal in millilitres. Every time the student taps the glass icon, 250 mL is added to today's total and the progress bar grows. At 8 p.m. a timer checks the total; if it is below the goal, the phone vibrates and shows a reminder.”
Identify (1) the purpose, (2) one function, (3) two inputs of different kinds, (4) one output, and (5) explain why the reminder code does not run in the order it is written.
(1) Mục đích: giúp học sinh uống đủ nước trong tuần thi — đây là vấn đề mà ứng dụng tồn tại để giải quyết. Câu “ứng dụng cộng 250 mL” không phải mục đích, vì nó chỉ tả việc ứng dụng làm.
(2) Một chức năng: mỗi lần chạm biểu tượng cốc, cộng 250 mL vào tổng của ngày và kéo dài thanh tiến độ.
(3) Hai đầu vào khác loại: mục tiêu mL do người dùng gõ (văn bản) và cú chạm vào biểu tượng cốc (xúc giác). Sự kiện đồng hồ 20 giờ cũng là một đầu vào, đến từ hệ thống chứ không từ người dùng.
(4) Một đầu ra: điện thoại rung kèm dòng nhắc trên màn hình (hoặc thanh tiến độ dài ra).
(5) Khối nhắc là trình xử lý của sự kiện hẹn giờ 20 giờ. Nó chỉ chạy khi sự kiện đó xảy ra, nên dù được viết ở đầu hay cuối tệp mã, nó luôn chạy sau mọi cú chạm trong ngày và đọc tổng mL đã được các cú chạm đó cập nhật.
Đọc xong rồi — làm thử ngay
Bài tập của chương Unit 1 — Creative Development gồm 14 câu trắc nghiệm và 5 đề tự luận. Đáp án hiện ngay khi chọn, miễn phí.