Master the 5-Step Problem-Solving Method, Question Type Analysis, and Key Exam Strategies 掌握5步解题法、题型分析与关键考试策略
Understanding question types is the first step to exam success. Each type has distinct characteristics and focus areas. 理解题型是考试成功的第一步。每种类型都有独特的特征和考点。
| Type类型 | Characteristics特征 | Key Focus Areas考点 | Example题号示例 |
|---|---|---|---|
| Pure Function纯函数 | No HTTP, no server, only input/output无HTTP、无server、只有输入输出 | Array ops, string handling, file I/O, logic数组操作、字符串处理、文件I/O、逻辑判断 | Q23 |
| REST APIREST API | Express routes, swagger.yamlExpress routes、swagger.yaml | HTTP status codes, routing, req/res handlingHTTP状态码、路由处理、请求响应 | Q24 |
| Business Logic业务逻辑 | Complex conditions, notification systems复杂条件判断、notification系统 | State machines, array search, string matching状态机、数组查找、字符串匹配 | Q25 |
| Testing测试 | .test.ts files.test.ts文件 | Jest, expect assertions, edge casesJest、expect、edge case | All questions各题都有 |
async function decontaminate(files: string[]): Promise<DecontaminateResult> {
const result = { attic: 0, bathroom: 0, bedroom: 0, kitchen: 0 };
for (const file of files) {
const content = await fs.promises.readFile(file, 'utf-8');
const locations = content.split('\n').filter(Boolean);
for (const loc of locations) {
if (loc in result) {
result[loc as keyof typeof result]++;
}
}
}
return result;
}
| Endpoint | Method | Parameters参数 | Returns返回 |
|---|---|---|---|
| /clear | DELETE | none无 | {} |
| /user | POST | header + body | {userId} |
| /message | POST | body | {msgId} |
| /message/{from}/{to} | GET | path + query | {msgs} |
| /message/{id} | PUT | path + body | {msg} |
interface DataStore {
users: User[]; // {userId, username}
messages: Message[]; // {messageId, from, to, message}
}
let dataStore: DataStore = { users: [], messages: [] };
let nextUserId = 1;
let nextMessageId = 1;
// brooms.ts - core business logic
function addUser(username: string, role: string): Result {
if (role !== 'moderator') return { error: 'UNAUTHORIZED' };
if (username.length < 2) return { error: 'INVALID_USERNAME' };
const userId = nextUserId++;
dataStore.users.push({ userId, username });
return { userId };
}
// server.ts - HTTP wrapper
import { addUser } from './brooms';
app.post('/user', (req, res) => {
const { username } = req.body;
const role = req.header('role');
const result = addUser(username, role || '');
if ('error' in result) {
const statusCode = getStatusCode(result.error);
return res.status(statusCode).json(result);
}
res.json(result);
});
Success - Request completed成功 - 请求完成
Client input error (INVALID_*)客户端输入错误 (INVALID_*)
No permission / not logged in没权限 (UNAUTHORIZED)
Access denied (known user)禁止访问 (FORBIDDEN)
Resource not found找不到 (NOT_FOUND)
Internal server error服务器内部错误
✗ Test 1: status='do not disturb' → false
✗ Test 2: channel在silenced里 → false
✓ Test 3: message包含@username → true
✓ Test 4: dm=true → true
✓ Test 5: channel在subscribed里 → true
notificationService(user, message):
│
├─ 1. dm === true → return true
│
├─ 2. content包含@{username} → return true
│
├─ 3. status === 'do not disturb' → return false
│
├─ 4. channel在silenced里 → return false
│
├─ 5. channel在subscribed里 → return true
│
└─ 6. 其他 → return false
function notificationService(user: User, message: Message): boolean {
// Rule 1: DM always notify
if (message.dm) return true;
// Rule 2: @mention always notify
if (message.content.includes(`@${user.username}`)) return true;
// Rule 3: Do not disturb blocks everything else
if (user.status === 'do not disturb') return false;
// Rule 4: Silenced channel
if (user.silenced.includes(message.channel)) return false;
// Rule 5: Subscribed channel
if (user.subscribed.includes(message.channel)) return true;
// Default: no notification
return false;
}
Use Map<number, User> instead of array不用数组存users,改用Map<number, User>
Key change:关键变化: users.get(userId) instead of而不是 users.find()
Use PUT instead of POST for creating users不用POST创建user,改用PUT
Key change:关键变化: PUT is idempotent - same result on repeat callsPUT是幂等的,重复调用结果相同
Require JWT token verification要求验证JWT token
Key change:关键变化: Parse token from header, verify signature需要解析header里的token,验证签名
Tests tell you the EXACT expectations. Don't guess - read the tests!test告诉你exact的期望。不要猜,看test!
Don't consider all edge cases at the start. Get the main flow working first.不要一开始就考虑所有edge case。让主流程跑通,再补全。
There's a reason they give you scratch paper. Draw decision trees and data flow diagrams.考试时给你草稿纸是有原因的。画决策树、数据流图。
TypeScript errors are helping you, not annoying you. Get types right first.TypeScript错误不是烦人,是帮你的。先把类型定义对。
Test your understanding with 30 comprehensive questions covering all exam topics. 通过30道综合题目测试你对所有考试内容的理解。
🎯 Start Final Review Quiz 开始期末复习测验