# QUY ƯỚC CODE

**<span style="font-size: 18.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">V. Quy ước đặt tên</span>**

**<span style="font-size: 13.5pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">9. Biến</span>**

- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Sử dụng camelCase</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Tên phải có ý nghĩa</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Không viết tắt khó hiểu</span>

<span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Không sử dụng tên như: a, data1, temp, test nếu không có ý nghĩa rõ ràng.</span>

<div align="center" class="MsoNormal" id="bkmrk--10" style="margin-bottom: .0001pt; text-align: center; line-height: normal;">---

</div>**<span style="font-size: 13.5pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">10. Class và Interface</span>**

- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Sử dụng PascalCase</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Tên phản ánh đúng chức năng</span>

<span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Ví dụ:</span>

- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">UserSyncService</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">AuthController</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">DataMappingRepository</span>

<span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Không đặt tên chung chung như: Service1, TestClass.</span>

<div align="center" class="MsoNormal" id="bkmrk--11" style="margin-bottom: .0001pt; text-align: center; line-height: normal;">---

</div>**<span style="font-size: 13.5pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">11. Tên file</span>**

- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Tên file trùng với class chính</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Không đặt tên file không rõ nghĩa</span>

<span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Không sử dụng các tên như: utils2, newfile, test.</span>

<div align="center" class="MsoNormal" id="bkmrk--12" style="margin-bottom: .0001pt; text-align: center; line-height: normal;">---

</div>**<span style="font-size: 18.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">VI. Cấu trúc và tổ chức code</span>**

**<span style="font-size: 13.5pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">12. Phân tầng rõ ràng</span>**

- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Controller không chứa business logic phức tạp</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Service không truy cập database trực tiếp nếu đã có repository layer</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Không viết toàn bộ logic trong một file duy nhất</span>

<span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Phải tuân thủ đúng kiến trúc đã thống nhất của dự án.</span>

<div align="center" class="MsoNormal" id="bkmrk--13" style="margin-bottom: .0001pt; text-align: center; line-height: normal;">---

</div>**<span style="font-size: 13.5pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">13. Hàm và logic</span>**

- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Một function chỉ nên thực hiện một nhiệm vụ</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Không viết function quá dài và khó theo dõi</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Logic phức tạp phải được tách nhỏ</span>

<span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Nếu một function vượt quá mức hợp lý và khó đọc, reviewer có quyền yêu cầu refactor.</span>

<div align="center" class="MsoNormal" id="bkmrk--14" style="margin-bottom: .0001pt; text-align: center; line-height: normal;">---

</div>**<span style="font-size: 13.5pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">14. Logging</span>**

- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Log phải có mục đích rõ ràng</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Không log dữ liệu nhạy cảm</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Không để log debug dư thừa trước khi merge</span>

<div align="center" class="MsoNormal" id="bkmrk--15" style="margin-bottom: .0001pt; text-align: center; line-height: normal;">---

</div>**<span style="font-size: 13.5pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">15. Xử lý lỗi</span>**

- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Không catch lỗi mà bỏ qua</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Không throw lỗi chung chung</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Message lỗi phải rõ ràng, có ngữ cảnh</span>

<span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Không để các khối catch rỗng hoặc bỏ qua exception.</span>

<div align="center" class="MsoNormal" id="bkmrk--16" style="margin-bottom: .0001pt; text-align: center; line-height: normal;">---

</div>**<span style="font-size: 13.5pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">16. Format và kiểm tra tự động</span>**

- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Bắt buộc sử dụng ESLint / Prettier theo cấu hình dự án</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Không merge nếu format sai</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Không thay đổi format toàn bộ file nếu không liên quan đến task</span>

<div align="center" class="MsoNormal" id="bkmrk--17" style="margin-bottom: .0001pt; text-align: center; line-height: normal;">---

</div>**<span style="font-size: 24.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman'; mso-font-kerning: 18.0pt;">VII. Trách nhiệm kỹ thuật</span>**

1. <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Code trước khi tạo PR phải:</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Chạy được</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Không lỗi compile</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Không làm hỏng chức năng cũ</span>

3. <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Người thực hiện task chịu trách nhiệm:</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Test lại trước khi merge</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Theo dõi lỗi phát sinh sau khi merge</span>

5. <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Không đổ lỗi cho quá trình merge nếu chưa kiểm tra kỹ trước đó.</span>

<div align="center" class="MsoNormal" id="bkmrk--18" style="margin-bottom: .0001pt; text-align: center; line-height: normal;">---

</div>**<span style="font-size: 24.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman'; mso-font-kerning: 18.0pt;">VIII. Xử lý vi phạm</span>**

**<span style="font-size: 13.5pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">17. Vi phạm mức độ 1 – Yêu cầu chỉnh sửa</span>**

<span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Áp dụng khi:</span>

- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Sai format</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Sai naming</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Commit message không đúng quy ước</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">PR thiếu mô tả</span>

<span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Hình thức xử lý:</span>

- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Yêu cầu chỉnh sửa trước khi approve</span>

<div align="center" class="MsoNormal" id="bkmrk--19" style="margin-bottom: .0001pt; text-align: center; line-height: normal;">---

</div>**<span style="font-size: 13.5pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">18. Vi phạm mức độ 2 – Từ chối merge</span>**

<span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Áp dụng khi:</span>

- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Không tuân thủ workflow</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Tự ý commit vào nhánh chính</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Không xử lý conflict</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Không test trước khi tạo PR</span>

<span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Hình thức xử lý:</span>

- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Từ chối merge</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Yêu cầu làm lại theo đúng quy trình</span>

<div align="center" class="MsoNormal" id="bkmrk--20" style="margin-bottom: .0001pt; text-align: center; line-height: normal;">---

</div>**<span style="font-size: 13.5pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">19. Vi phạm mức độ 3 – Đánh giá năng lực kỹ thuật</span>**

<span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Áp dụng khi:</span>

- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Lặp lại vi phạm nhiều lần</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Không tuân thủ quy ước dù đã được nhắc</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Gây ảnh hưởng nghiêm trọng đến hệ thống</span>

<span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Hình thức xử lý:</span>

- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Trao đổi trực tiếp</span>
- <span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Đánh giá lại mức độ phù hợp trong dự án</span>

<div align="center" class="MsoNormal" id="bkmrk--21" style="margin-bottom: .0001pt; text-align: center; line-height: normal;">---

</div>**<span style="font-size: 18.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">IX. Hiệu lực</span>**

<span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Quy định này có hiệu lực kể từ ngày ban hành và áp dụng cho toàn bộ thành viên tham gia phát triển dự án.</span>

<span style="font-size: 12.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 'Times New Roman';">Mọi thay đổi về workflow hoặc quy ước kỹ thuật phải được thống nhất trước khi áp dụng.</span>