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.

...全文
243 回复 打赏 收藏 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
内容概要:本文介绍了基于Matlab代码实现的电力系统机组组合优化调度方法,适用于IEEE14、IEEE30和IEEE118节点标准测试系统。该资源聚焦于电力系统中发电机组的优化调度问题,通过智能优化算法实现对机组启停、出力分配等决策的最优化,旨在降低运行成本、提升系统可靠性和经济性。文中系统阐述了从数学模型构建、多类型约束处理到优化算法设计与仿真实验验证的完整研究流程,并提供了可复现的Matlab代码,涵盖目标函数设定、约束条件建模及算法求解过程,适用于电力系统调度、能源优化等相关领域的科研与教学实践。; 适合人群:具备电力系统分析、运筹学基础及Matlab编程能力的高校学生、科研人员和工程技术人员,尤其适合从事电力系统优化、智能算法应用研究的研究生与青年学者。; 使用场景及目标:①用于电力系统机组组合(UC)问题的教学实验与课程设计;②支撑科研工作中对遗传算法、粒子群算法等智能优化算法在电力系统调度中应用的研究;③为含可再生能源接入的现代电网调度提供仿真平台与技术参考,助力低碳电力系统规划与运行。; 阅读建议:建议读者结合电力系统调度理论与优化建模知识,深入理解机组组合问题的数学本质与物理约束,再通过Matlab代码进行仿真实践,重点关注算法收敛性、多目标权衡策略与不同测试系统间的性能对比,以实现理论与实践的深度融合。
内容概要:本文研究了一种基于TCN-BiGRU-Attention混合神经网络模型的风电功率预测方法,旨在提升预测精度。该模型融合了时间卷积网络(TCN)对局部时序特征的强大提取能力、双向门控循环单元(BiGRU)对时间序列前后依赖关系的双向捕捉能力,以及注意力(Attention)机制对关键时间步特征的自适应加权聚焦能力。研究采用多变量输入方式,综合纳入风速、风向、温度等多种气象因素作为输入特征,实现风电功率的单步预测。通过对实际风电场数据的实验验证,该模型在预测精度方面相较于单一模型或其他组合模型展现出显著优势,有效降低了预测误差。; 适合人群:具备一定机器学习与深度学习基础,从事新能源预测、电力系统调度或相关领域研究的科研人员与工程技术人员。; 使用场景及目标:①应用于风电场功率实时预测,提升电网调度的稳定性与安全性;②为电力市场交易、储能配置和可再生能源消纳提供高精度数据支持;③作为深度学习模型融合设计的参考案例,推动时序预测技术的发展。; 阅读建议:此资源提供了完整的Matlab代码实现,读者在学习时应重点关注模型结构的设计原理、多变量特征的处理方式以及Attention机制的融入方法,建议结合代码进行复现实验,调整参数以深入理解各组件对最终预测性能的影响。
内容概要:本文聚焦于非线性值迭代自适应动态规划(ADP)算法的研究,通过复现Matlab代码深入探讨离散时间非线性系统的策略迭代方法。文章系统阐述了ADP算法的核心原理,重点分析了其在处理非线性系统时的优势与挑战,并详细展示了值迭代与策略迭代在优化控制策略中的具体实现过程。研究强调了通过迭代优化实现系统性能最大化的方法论,同时提供了完整的代码与文档资源,便于读者进行深入学习与实践。; 适合人群:具备一定编程基础,尤其是对Matlab有初步了解的研发人员,以及从事控制理论、自动化、人工智能等领域的研究人员和研究生。; 使用场景及目标:① 为控制理论与自动化领域的研究者提供非线性系统控制策略设计与实现的实用案例;② 为学生和初学者提供学习与理解自适应动态规划算法及其在非线性系统中应用的实践机会;③ 推动相关领域的学术交流与技术进步,激发更多研究者投身于非线性控制系统的研究与优化。; 阅读建议:此资源兼具理论深度与实践指导。建议读者在学习过程中紧密结合理论知识与代码操作,动手实现算法,并通过调整参数或应用场景来深化理解。同时,可参考提供的参考资料,进一步探索自适应动态规划领域的最新研究进展。

165

社区成员

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

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