FocusFlow β Sprint Code Standards
目录
- Project Overview
- Introduction
- Part 1: Language-Specific Coding Standards
- 1. Python (Backend / Scripts)
- 2. JavaScript / TypeScript (Frontend - React/React Native)
- 3. HTML & CSS
- Part 2: Git & Version Control Workflow (CRITICAL)
- Part 3: Pre-Merge Quality Checklist
- Conclusion
Project Overview
| Course | 2501_MU_SE_FZU |
|---|---|
| Assignment Requirement | Sixth Assignment - Beta Sprint |
| Team Name | Focus_2025 |
| Goal of this assignment | Clarify Code Standards, Sprint Tasks, and Plans for the team Beta Sprint |
| Other references | IEEE Std 830-1998, GB/T 8567-2006 |
Introduction
To ensure the code quality, maintainability, and collaborative efficiency of the FocusFlow project, our team has established and unanimously agreed to adhere to the following code standards. These standards encompass syntax style, engineering practices, and collaboration workflows. They represent a key improvement distilled from our "learning by doing" experience in the Alpha phase.
Part 1: Language-Specific Coding Standards
1. Python (Backend / Scripts)
- Reference: PEP 8.
- Naming:
- Variables & Functions:
snake_case(e.g.,calculate_session_duration) - Classes:
CamelCase(e.g.,UserProfileManager) - Constants:
ALL_CAPS_WITH_UNDERSCORES(e.g.,MAX_FOCUS_BLOCK)
- Variables & Functions:
- Style:
- Indentation: 4 spaces.
- Maximum Line Length: 80 characters.
- Spacing: Two blank lines between top-level functions/classes. One blank line between methods.
- Documentation:
- Use docstrings for all modules, classes, and public functions (Google or NumPy style).
- Use inline comments (
#) sparingly for complex logic only.
- Key Practices:
- Use context managers (
withstatement) or explicittry...except...finallyblocks for resource management (files, DB connections). - Always use parameterized queries with the database driver. NEVER use string formatting for SQL statements.
- Hash passwords using a dedicated library (e.g.,
bcrypt,passlib) before storage.
- Use context managers (
2. JavaScript / TypeScript (Frontend - React/React Native)
- Reference: Airbnb JavaScript/React Style Guide (adapted).
- Naming:
- Variables & Functions:
camelCase(e.g.,formatTimerDisplay) - React Components:
PascalCase(e.g.,TaskCard,FocusTimer) - Constants:
ALL_CAPS_WITH_UNDERSCORESfor true constants.
- Variables & Functions:
- Style:
- Indentation: 2 spaces.
- Maximum Line Length: 80 characters.
- Semicolons: Required.
- Quotes: Use single quotes (
') for strings, backticks (`) for template literals.
- React-Specific:
- Use functional components with Hooks.
- Define props and state using TypeScript interfaces or PropTypes.
- Keep components small and focused on a single responsibility.
- Key Practices:
- For API calls, use a centralized service (e.g.,
apiClient.js) built onaxiosorfetch. - Use the
useEffectcleanup function to prevent memory leaks (e.g., clear timers, unsubscribe).
- For API calls, use a centralized service (e.g.,
3. HTML & CSS
- HTML:
- Use semantic tags (
<header>,<main>,<section>,<article>). - Indentation: 2 spaces.
- Attribute values: Use double quotes (
href="...").
- Use semantic tags (
- CSS / Styled-Components:
- Naming: Use the BEM (Block__Element--Modifier) methodology for class names (e.g.,
.task-card,.task-card__title,.task-card--completed). - Organization: Group related properties logically (e.g., Box Model -> Positioning -> Typography -> Visual).
- Specificity: Avoid
!importantand overly specific selectors (e.g.,div#id .class). Aim for low specificity.
- Naming: Use the BEM (Block__Element--Modifier) methodology for class names (e.g.,
Part 2: Git & Version Control Workflow (CRITICAL)
This section directly addresses a key failure from our Alpha retrospective.
Branch Strategy:
-
main: Always deployable. Direct commits are forbidden. -
develop: Integration branch for features. Most PRs target here. -
feature/*: Branches for new development (e.g.,feature/password-reset,feature/task-cards). -
hotfix/*: Branches for critical bugs inmain.
-
Commit Convention:
- Format:
<type>(<scope>): <subject>(Based on Conventional Commits). - Types:
feat,fix,docs,style,refactor,test,chore. - Example:
feat(F1): implement new password reset confirmation screenorfix(F3): align task card layout on mobile.
- Format:
Pull Request (PR) Process:
- All changes must be introduced via a PR from a feature/hotfix branch.
- A PR requires at least one approval from a team member other than the author before merging.
- The PR description must link to the relevant Issue (e.g.,
Closes #12). - The PR must pass the mandatory pre-merge checklist (see Part 3).
Part 3: Pre-Merge Quality Checklist
Before any PR can be merged, the author must confirm the following:
- Code Functionality: The feature/bugfix works as described in the Issue.
- Self-Review: I have reviewed my own code for obvious errors and style violations.
- Linting: Code passes ESLint (for JS/TS) and Flake8/Black (for Python) without errors.
- Testing: For backend logic, corresponding unit tests are added/updated. For frontend components, manual testing has been performed on target devices/browsers.
- No Breaking Changes: The change does not break existing functionality (verified by running the core smoke tests).
- Documentation: Any necessary updates to README, API docs, or inline comments have been made.
Conclusion
These standards are not static rules but a living agreement. They are enforced through peer review in our PR process and serve as our shared foundation for writing clean, secure, and collaborative code. By adhering to them, we aim to eliminate the chaos of the Alpha phase and build FocusFlow into a robust, professional application.
相关推荐
Microsoft.WinDbg-1.2610.1001.0-x64
Microsoft.WinDbg-1.2610.1001.0-x64
PDF发票内容提取排版并结构化导出xlsx/cvs嵌入式ptyhon
【本地发票提取工具】 核心优势:不依赖传统粗糙 OCR,基于文字排版结构进行精准提取。仅“税网”下载及税网邮件发送的原版 PDF 发票(开票软件发送的不太支持)能实现开票明细级的秒级本地提取,告别只能提抬头、总额的尴尬。 可免费试用 3 天! 【用前须知】 去微软官网下载VC_redist.x64.exe运行修复运行库(必要的前置操作),之后再解压本工具rar,运行本exe即可。 VC_redist.x64.exe官网永久下载地址 https://learn.microsoft.com/zh-cn/cpp/windows/latest-supported-vc-redist 【安全须知】 个人开发暂未做代码签名,杀软可能会有误报拦截。遇到拦截请在杀软中添加信任/白名单即可。 VirusTotal扫描结果 2/61,主流杀软均通过,个别引擎因无签名误报。官网 virustotal.com 点击页面中间显眼的 “Choose file”(选择文件)按钮上传扫描。
Flask校园二手交易平台课设
这是一份基于 Flask + SQLite 的校园二手交易平台课程设计完整资料,包含实验报告(Markdown、HTML、PDF 三种格式)、全部 Python 源码、8 个 Jinja2 页面模板、5 张运行截图、答辩 PPT。学生注册账号后发布闲置物品,同校同学按分类翻、按关键词搜,看中了在详情页留言咨询,管理员能下架违规商品。不接支付不做物流,买卖双方线下交易,平台只负责信息展示和沟通,一个学期课设能做完。 系统功能:用户注册登录登出,session 维持登录态;发布商品填标题、描述、价格、选六类分类,图片可选上传不强制;首页卡片网格展示在售商品,顶部搜索框按标题描述模糊匹配,下方分类按钮筛选,搜索和筛选可组合;商品详情页展示大图、完整描述、卖家昵称,登录用户能留言咨询;我的发布页能看自己挂过的所有商品并删除;管理员后台能看全部商品,一键下架违规品或恢复在售。 几个值得参考的实现点:密码用 Werkzeug 哈希加盐存储;登录接口不区分"用户不存在"和"密码错误",防枚举用户名;图片上传限制后缀和 2MB,文件名随机串重命名,防覆盖和传脚本;分类和搜索筛选组合用动态拼 SQL;首次启动自动建表写管理员账号;Bootstrap 5 栅格,手机浏览器也能看。 适合正在做 Web 课程设计、Python 后端入门的学生,以及想学习"Flask 蓝图 + SQLite + 登录鉴权 + 文件上传"完整小项目的自学者。拿到手后 cd src,pip install -r requirements.txt,python app.py,浏览器开 http://127.0.0.1:5000 即可,管理员账号 admin/admin123,普通用户自行注册。
《低秩加稀疏模型的高效动态平行MRI重建.zip
1.版本:matlab2014a/2019b/2024b 2.附赠案例数据可直接运行。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
物联网与短距离无线通信技术(第3版)PPT课件
物联网与短距离无线通信技术(第3版)PPT课件


