FocusFlow β Sprint Code Standards

FOCUS_2025_SE 2025-12-28 15:05:03

目录

  • 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

Course2501_MU_SE_FZU
Assignment RequirementSixth Assignment - Beta Sprint
Team NameFocus_2025
Goal of this assignmentClarify Code Standards, Sprint Tasks, and Plans for the team Beta Sprint
Other referencesIEEE 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)
  • 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 (with statement) or explicit try...except...finally blocks 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.

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_UNDERSCORES for true constants.
  • 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 on axios or fetch.
    • Use the useEffect cleanup function to prevent memory leaks (e.g., clear timers, unsubscribe).

3. HTML & CSS

  • HTML:
    • Use semantic tags (<header>, <main>, <section>, <article>).
    • Indentation: 2 spaces.
    • Attribute values: Use double quotes (href="...").
  • 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 !important and overly specific selectors (e.g., div#id .class). Aim for low specificity.

Part 2: Git & Version Control Workflow (CRITICAL)

This section directly addresses a key failure from our Alpha retrospective.

  1. 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 in main.
  2. 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 screen or fix(F3): align task card layout on mobile.
  3. 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.

...全文
216 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
内容概要:本文围绕基于多面体最大内近似的电动汽车集群聚合及微电网经济调度展开研究,提出了一种面向大规模电动汽车集群的灵活资源聚合建模方法。该方法通过构建电动汽车充放电行为可行域的内近似模型,利用几何表征与数学优化手段将其等效为可参与电网互动的聚合资源,并集成至微电网经济调度框架中,以提升系统运行的经济性与对可再生能源的消纳能力。研究系统阐述了内近似建模的理论基础、建模流程及其与调度优化模型的耦合机制,并通过Matlab代码实现了完整的仿真验证,充分展示了该方法在降低运行成本、增强系统灵活性方面的有效性与应用潜力。; 适合人群:具备电力系统分析、凸优化理论及Matlab编程基础的研究生、科研人员,以及从事新能源调度、电动汽车聚合、需求侧响应等领域的工程技术人员。; 使用场景及目标:①研究大规模电动汽车集群的灵活性资源聚合建模与可行性域刻画方法;②支撑微电网或主动配电网的经济调度与优化决策制定;③为高比例可再生能源接入的电力系统提供基于需求侧响应的解决方案;④为科研人员提供可复现的算法代码,支持进一步的创新与拓展研究。; 阅读建议:建议读者结合Matlab代码逐模块学习,重点理解多面体可行域的内近似构造逻辑与优化求解器的接口设计,同时可延伸学习外近似、列与约束生成(C&CG)算法等鲁棒优化技术,以深化对不确定性下电力系统优化问题的全面认知。
内容概要:本文是关于“永磁同步机全家桶”的综合性技术资源汇总,聚焦于永磁同步电机(PMSM)的全速域无传感器控制技术,系统涵盖了基于高频信号注入与自适应滑模观测器(SMO)的加权融合方法、混合观测器与加权切换策略等多种先进控制算法的仿真研究。文档深入剖析了从零速到高速各工况下观测器的设计原理,包括信号耦合机理、相位校正机制及平滑切换策略,并依托Simulink平台实现了完整的仿真实例,有效解决了传统机械传感器带来的成本高、可靠性差等问题,显著提升了电机控制系统的鲁棒性与动态精度。此外,该资源包还整合了智能优化算法、机器学习、电力系统优化、路径规划等多个科研方向的MATLAB/Simulink代码与论文复现案例,构建了一个面向科研与工程应用的完整技术生态体系。; 适合人群:具备一定电气工程、自动化或控制理论基础,从事电机控制、新能源系统、电力电子等相关领域的研究生、科研人员及工程技术人员。; 使用场景及目标:①深入理解永磁同步电机无传感器控制的核心算法原理与实现方式;②开展高性能电机控制系统的仿真验证与算法优化;③作为科研项目、毕业设计或学术论文复现的技术支撑材料,加速研究进程与成果转化。; 阅读建议:建议结合文中提供的Simulink模型与Matlab代码同步实践,重点关注不同观测器在高低速切换时的动态响应与稳定性表现,同时可拓展学习文档中关联的优化算法与系统建模技术,以构建完整的科研技术体系。

164

社区成员

发帖
与我相关
我的任务
社区描述
2501_MU_SE_FZU
软件工程 高校
社区管理员
  • FZU_SE_LQF
  • 助教_林日臻
  • 朱仕君
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧