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.

...全文
188 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
内容概要:本文系统研究了构网型变流器的正负序阻抗解耦特性及其在弱电网环境下的稳定性表现,重点依托Matlab/Simulink仿真平台,构建了详细的阻抗数学模型,设计了解耦控制策略,并采用小信号扫频法进行频域辨识与稳定性验证。研究深入探讨了构网型变流器与传统跟网型逆变器在正负序阻抗特性上的本质差异,结合虚拟同步发电机(VSG)等先进控制技术,分析其在抑制宽频带振荡、削弱锁相环动态耦合等方面的优越性。文中不仅提供了完整的仿真模型与MATLAB代码实现,还整合了光伏、风电、储能、微电网等多类新能源系统的阻抗建模与稳定性分析资源,形成了一套面向新型电力系统稳定性的综合性技术资料体系,具有较强的科研复现与工程参考价值。; 适合人群:面向具备电力电子、电力系统自动化、新能源并网等专业背景的研究生、高校教师及工程技术人员,特别适用于从事阻抗建模、小干扰稳定性分析、宽频振荡机理研究以及撰写高水平学术论文的科研工作者。; 使用场景及目标:①掌握构网型变流器正负序阻抗建模与扫频辨识的仿真方法;②深入理解VSG等构网型控制在弱电网中提升稳定性的内在机理;③复现顶刊论文中的阻抗分析流程与稳定性判据应用;④利用提供的成熟模型与代码加速科研进程,支撑课题研究与学术成果产出。; 阅读建议:建议结合文中提供的Simulink模型与MATLAB代码,按照“理论建模—仿真搭建—扫频激励—频响提取—Nyquist判据分析”的完整流程进行实践操作,重点关注扫频信号的注入方式、频率范围设置及阻抗曲线的物理意义解读,并参考博士论文复现案例深化对复杂动态耦合问题的理解。

164

社区成员

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

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