1. How to Do Code Review Better
| Requirement | Items |
|---|---|
| Requirements for the committer | Small granularity Atomicity With comments Tool checks |
| Requirements for the reviewer | First conventions Second logic & performance Third design |
| Requirements for the team | Reviewing the old to learn the new |
2. Define a Code Review Checklist
| Requirement | Items |
|---|---|
| Naming | Variable names Class naming Method naming Parameter naming |
| Code length | Classes no longer than 1000 lines Methods no longer than 100 lines |
| Conditional nesting | Avoid nesting multiple if and loop statements Avoid overly long conditions |
| Parameter and return value checks | At most 3 parameters recommended Validate parameters (e.g. null checks, container length) Validate return values (e.g. null checks, container length) |
| Reuse of well-encapsulated code | Does the interface use shared code libraries, such as Kresource, Kcontent, KPackageManager, etc. |
| Comments | Do classes, key steps, and external interfaces have comments |
3. Look at Logic & Performance
| Requirement | Items |
|---|---|
| Main-thread logic checks | Avoid time-consuming operations such as file and network I/O on the main thread |
| Threshold checks | Are access frequencies set, and is there a cap Are file sizes and counts capped Is network traffic capped |
| Multithreading issues | Does it produce dirty data Are synchronization locks used correctly |
| Memory leaks | Are resource I/O streams closed Are image resources recycled Are list objects reused |
| IPC checks | Frequent IPC causes jank |
4. Design
| Requirement | Items |
|---|---|
| Robustness | Boundary condition checks Fault tolerance |
| Security | Do critical features have permission checks (root-related interfaces) |
| Single responsibility | A class does only one thing |
| Code coupling | Program to interfaces Eliminate duplicate code Open-closed principle |
5. Key Points of Code Review
Purpose of Code Review
Code quality, better communication, backing each other up, technical atmosphere, cultural continuityHow to Do Code Review
- Essential elements
- Coding conventions
- Review guidelines
- Execution points
- Persist consistently
- Summarize and optimize
- Incentive mechanisms
- High-quality submission
- Efficient review
